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/machinelearningservices/2025-04-01/batchdeployment/README.md b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/README.md new file mode 100644 index 00000000000..82c863772d3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/README.md @@ -0,0 +1,99 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/batchdeployment` Documentation + +The `batchdeployment` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/batchdeployment" +``` + + +### Client Initialization + +```go +client := batchdeployment.NewBatchDeploymentClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BatchDeploymentClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := batchdeployment.NewDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "batchEndpointName", "deploymentName") + +payload := batchdeployment.BatchDeploymentTrackedResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `BatchDeploymentClient.Delete` + +```go +ctx := context.TODO() +id := batchdeployment.NewDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "batchEndpointName", "deploymentName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `BatchDeploymentClient.Get` + +```go +ctx := context.TODO() +id := batchdeployment.NewDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "batchEndpointName", "deploymentName") + +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: `BatchDeploymentClient.List` + +```go +ctx := context.TODO() +id := batchdeployment.NewBatchEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "batchEndpointName") + +// alternatively `client.List(ctx, id, batchdeployment.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, batchdeployment.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `BatchDeploymentClient.Update` + +```go +ctx := context.TODO() +id := batchdeployment.NewDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "batchEndpointName", "deploymentName") + +payload := batchdeployment.PartialBatchDeploymentPartialMinimalTrackedResourceWithProperties{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/batchdeployment/client.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/client.go new file mode 100644 index 00000000000..adcef61716d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/client.go @@ -0,0 +1,26 @@ +package batchdeployment + +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 BatchDeploymentClient struct { + Client *resourcemanager.Client +} + +func NewBatchDeploymentClientWithBaseURI(sdkApi sdkEnv.Api) (*BatchDeploymentClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "batchdeployment", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating BatchDeploymentClient: %+v", err) + } + + return &BatchDeploymentClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchdeployment/constants.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/constants.go new file mode 100644 index 00000000000..e0f08a31d9b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/constants.go @@ -0,0 +1,283 @@ +package batchdeployment + +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 BatchDeploymentConfigurationType string + +const ( + BatchDeploymentConfigurationTypeModel BatchDeploymentConfigurationType = "Model" + BatchDeploymentConfigurationTypePipelineComponent BatchDeploymentConfigurationType = "PipelineComponent" +) + +func PossibleValuesForBatchDeploymentConfigurationType() []string { + return []string{ + string(BatchDeploymentConfigurationTypeModel), + string(BatchDeploymentConfigurationTypePipelineComponent), + } +} + +func (s *BatchDeploymentConfigurationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBatchDeploymentConfigurationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBatchDeploymentConfigurationType(input string) (*BatchDeploymentConfigurationType, error) { + vals := map[string]BatchDeploymentConfigurationType{ + "model": BatchDeploymentConfigurationTypeModel, + "pipelinecomponent": BatchDeploymentConfigurationTypePipelineComponent, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BatchDeploymentConfigurationType(input) + return &out, nil +} + +type BatchLoggingLevel string + +const ( + BatchLoggingLevelDebug BatchLoggingLevel = "Debug" + BatchLoggingLevelInfo BatchLoggingLevel = "Info" + BatchLoggingLevelWarning BatchLoggingLevel = "Warning" +) + +func PossibleValuesForBatchLoggingLevel() []string { + return []string{ + string(BatchLoggingLevelDebug), + string(BatchLoggingLevelInfo), + string(BatchLoggingLevelWarning), + } +} + +func (s *BatchLoggingLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBatchLoggingLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBatchLoggingLevel(input string) (*BatchLoggingLevel, error) { + vals := map[string]BatchLoggingLevel{ + "debug": BatchLoggingLevelDebug, + "info": BatchLoggingLevelInfo, + "warning": BatchLoggingLevelWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BatchLoggingLevel(input) + return &out, nil +} + +type BatchOutputAction string + +const ( + BatchOutputActionAppendRow BatchOutputAction = "AppendRow" + BatchOutputActionSummaryOnly BatchOutputAction = "SummaryOnly" +) + +func PossibleValuesForBatchOutputAction() []string { + return []string{ + string(BatchOutputActionAppendRow), + string(BatchOutputActionSummaryOnly), + } +} + +func (s *BatchOutputAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBatchOutputAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBatchOutputAction(input string) (*BatchOutputAction, error) { + vals := map[string]BatchOutputAction{ + "appendrow": BatchOutputActionAppendRow, + "summaryonly": BatchOutputActionSummaryOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BatchOutputAction(input) + return &out, nil +} + +type DeploymentProvisioningState string + +const ( + DeploymentProvisioningStateCanceled DeploymentProvisioningState = "Canceled" + DeploymentProvisioningStateCreating DeploymentProvisioningState = "Creating" + DeploymentProvisioningStateDeleting DeploymentProvisioningState = "Deleting" + DeploymentProvisioningStateFailed DeploymentProvisioningState = "Failed" + DeploymentProvisioningStateScaling DeploymentProvisioningState = "Scaling" + DeploymentProvisioningStateSucceeded DeploymentProvisioningState = "Succeeded" + DeploymentProvisioningStateUpdating DeploymentProvisioningState = "Updating" +) + +func PossibleValuesForDeploymentProvisioningState() []string { + return []string{ + string(DeploymentProvisioningStateCanceled), + string(DeploymentProvisioningStateCreating), + string(DeploymentProvisioningStateDeleting), + string(DeploymentProvisioningStateFailed), + string(DeploymentProvisioningStateScaling), + string(DeploymentProvisioningStateSucceeded), + string(DeploymentProvisioningStateUpdating), + } +} + +func (s *DeploymentProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeploymentProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeploymentProvisioningState(input string) (*DeploymentProvisioningState, error) { + vals := map[string]DeploymentProvisioningState{ + "canceled": DeploymentProvisioningStateCanceled, + "creating": DeploymentProvisioningStateCreating, + "deleting": DeploymentProvisioningStateDeleting, + "failed": DeploymentProvisioningStateFailed, + "scaling": DeploymentProvisioningStateScaling, + "succeeded": DeploymentProvisioningStateSucceeded, + "updating": DeploymentProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeploymentProvisioningState(input) + return &out, nil +} + +type ReferenceType string + +const ( + ReferenceTypeDataPath ReferenceType = "DataPath" + ReferenceTypeId ReferenceType = "Id" + ReferenceTypeOutputPath ReferenceType = "OutputPath" +) + +func PossibleValuesForReferenceType() []string { + return []string{ + string(ReferenceTypeDataPath), + string(ReferenceTypeId), + string(ReferenceTypeOutputPath), + } +} + +func (s *ReferenceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseReferenceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseReferenceType(input string) (*ReferenceType, error) { + vals := map[string]ReferenceType{ + "datapath": ReferenceTypeDataPath, + "id": ReferenceTypeId, + "outputpath": ReferenceTypeOutputPath, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ReferenceType(input) + return &out, nil +} + +type SkuTier string + +const ( + SkuTierBasic SkuTier = "Basic" + SkuTierFree SkuTier = "Free" + SkuTierPremium SkuTier = "Premium" + SkuTierStandard SkuTier = "Standard" +) + +func PossibleValuesForSkuTier() []string { + return []string{ + string(SkuTierBasic), + string(SkuTierFree), + string(SkuTierPremium), + string(SkuTierStandard), + } +} + +func (s *SkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuTier(input string) (*SkuTier, error) { + vals := map[string]SkuTier{ + "basic": SkuTierBasic, + "free": SkuTierFree, + "premium": SkuTierPremium, + "standard": SkuTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuTier(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchdeployment/id_batchendpoint.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/id_batchendpoint.go new file mode 100644 index 00000000000..7ea4a76b10e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/id_batchendpoint.go @@ -0,0 +1,139 @@ +package batchdeployment + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BatchEndpointId{}) +} + +var _ resourceids.ResourceId = &BatchEndpointId{} + +// BatchEndpointId is a struct representing the Resource ID for a Batch Endpoint +type BatchEndpointId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + BatchEndpointName string +} + +// NewBatchEndpointID returns a new BatchEndpointId struct +func NewBatchEndpointID(subscriptionId string, resourceGroupName string, workspaceName string, batchEndpointName string) BatchEndpointId { + return BatchEndpointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + BatchEndpointName: batchEndpointName, + } +} + +// ParseBatchEndpointID parses 'input' into a BatchEndpointId +func ParseBatchEndpointID(input string) (*BatchEndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&BatchEndpointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BatchEndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBatchEndpointIDInsensitively parses 'input' case-insensitively into a BatchEndpointId +// note: this method should only be used for API response data and not user input +func ParseBatchEndpointIDInsensitively(input string) (*BatchEndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&BatchEndpointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BatchEndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BatchEndpointId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.BatchEndpointName, ok = input.Parsed["batchEndpointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "batchEndpointName", input) + } + + return nil +} + +// ValidateBatchEndpointID checks that 'input' can be parsed as a Batch Endpoint ID +func ValidateBatchEndpointID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBatchEndpointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Batch Endpoint ID +func (id BatchEndpointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/batchEndpoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.BatchEndpointName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Batch Endpoint ID +func (id BatchEndpointId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticBatchEndpoints", "batchEndpoints", "batchEndpoints"), + resourceids.UserSpecifiedSegment("batchEndpointName", "batchEndpointName"), + } +} + +// String returns a human-readable description of this Batch Endpoint ID +func (id BatchEndpointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Batch Endpoint Name: %q", id.BatchEndpointName), + } + return fmt.Sprintf("Batch Endpoint (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchdeployment/id_batchendpoint_test.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/id_batchendpoint_test.go new file mode 100644 index 00000000000..b8105f503c8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/id_batchendpoint_test.go @@ -0,0 +1,327 @@ +package batchdeployment + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BatchEndpointId{} + +func TestNewBatchEndpointID(t *testing.T) { + id := NewBatchEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "batchEndpointName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.BatchEndpointName != "batchEndpointName" { + t.Fatalf("Expected %q but got %q for Segment 'BatchEndpointName'", id.BatchEndpointName, "batchEndpointName") + } +} + +func TestFormatBatchEndpointID(t *testing.T) { + actual := NewBatchEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "batchEndpointName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/batchEndpoints/batchEndpointName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBatchEndpointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BatchEndpointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/batchEndpoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/batchEndpoints/batchEndpointName", + Expected: &BatchEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + BatchEndpointName: "batchEndpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/batchEndpoints/batchEndpointName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBatchEndpointID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.BatchEndpointName != v.Expected.BatchEndpointName { + t.Fatalf("Expected %q but got %q for BatchEndpointName", v.Expected.BatchEndpointName, actual.BatchEndpointName) + } + + } +} + +func TestParseBatchEndpointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BatchEndpointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/batchEndpoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/bAtChEnDpOiNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/batchEndpoints/batchEndpointName", + Expected: &BatchEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + BatchEndpointName: "batchEndpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/batchEndpoints/batchEndpointName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/bAtChEnDpOiNtS/bAtChEnDpOiNtNaMe", + Expected: &BatchEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + BatchEndpointName: "bAtChEnDpOiNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/bAtChEnDpOiNtS/bAtChEnDpOiNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBatchEndpointIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.BatchEndpointName != v.Expected.BatchEndpointName { + t.Fatalf("Expected %q but got %q for BatchEndpointName", v.Expected.BatchEndpointName, actual.BatchEndpointName) + } + + } +} + +func TestSegmentsForBatchEndpointId(t *testing.T) { + segments := BatchEndpointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BatchEndpointId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchdeployment/id_deployment.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/id_deployment.go new file mode 100644 index 00000000000..4a91c959a5c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/id_deployment.go @@ -0,0 +1,148 @@ +package batchdeployment + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DeploymentId{}) +} + +var _ resourceids.ResourceId = &DeploymentId{} + +// DeploymentId is a struct representing the Resource ID for a Deployment +type DeploymentId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + BatchEndpointName string + DeploymentName string +} + +// NewDeploymentID returns a new DeploymentId struct +func NewDeploymentID(subscriptionId string, resourceGroupName string, workspaceName string, batchEndpointName string, deploymentName string) DeploymentId { + return DeploymentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + BatchEndpointName: batchEndpointName, + DeploymentName: deploymentName, + } +} + +// ParseDeploymentID parses 'input' into a DeploymentId +func ParseDeploymentID(input string) (*DeploymentId, error) { + parser := resourceids.NewParserFromResourceIdType(&DeploymentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DeploymentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDeploymentIDInsensitively parses 'input' case-insensitively into a DeploymentId +// note: this method should only be used for API response data and not user input +func ParseDeploymentIDInsensitively(input string) (*DeploymentId, error) { + parser := resourceids.NewParserFromResourceIdType(&DeploymentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DeploymentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DeploymentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.BatchEndpointName, ok = input.Parsed["batchEndpointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "batchEndpointName", input) + } + + if id.DeploymentName, ok = input.Parsed["deploymentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "deploymentName", input) + } + + return nil +} + +// ValidateDeploymentID checks that 'input' can be parsed as a Deployment ID +func ValidateDeploymentID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseDeploymentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Deployment ID +func (id DeploymentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/batchEndpoints/%s/deployments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.BatchEndpointName, id.DeploymentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Deployment ID +func (id DeploymentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticBatchEndpoints", "batchEndpoints", "batchEndpoints"), + resourceids.UserSpecifiedSegment("batchEndpointName", "batchEndpointName"), + resourceids.StaticSegment("staticDeployments", "deployments", "deployments"), + resourceids.UserSpecifiedSegment("deploymentName", "deploymentName"), + } +} + +// String returns a human-readable description of this Deployment ID +func (id DeploymentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Batch Endpoint Name: %q", id.BatchEndpointName), + fmt.Sprintf("Deployment Name: %q", id.DeploymentName), + } + return fmt.Sprintf("Deployment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchdeployment/id_deployment_test.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/id_deployment_test.go new file mode 100644 index 00000000000..1ddb6202666 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/id_deployment_test.go @@ -0,0 +1,372 @@ +package batchdeployment + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DeploymentId{} + +func TestNewDeploymentID(t *testing.T) { + id := NewDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "batchEndpointName", "deploymentName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.BatchEndpointName != "batchEndpointName" { + t.Fatalf("Expected %q but got %q for Segment 'BatchEndpointName'", id.BatchEndpointName, "batchEndpointName") + } + + if id.DeploymentName != "deploymentName" { + t.Fatalf("Expected %q but got %q for Segment 'DeploymentName'", id.DeploymentName, "deploymentName") + } +} + +func TestFormatDeploymentID(t *testing.T) { + actual := NewDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "batchEndpointName", "deploymentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/batchEndpoints/batchEndpointName/deployments/deploymentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDeploymentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DeploymentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/batchEndpoints", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/batchEndpoints/batchEndpointName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/batchEndpoints/batchEndpointName/deployments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/batchEndpoints/batchEndpointName/deployments/deploymentName", + Expected: &DeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + BatchEndpointName: "batchEndpointName", + DeploymentName: "deploymentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/batchEndpoints/batchEndpointName/deployments/deploymentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDeploymentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.BatchEndpointName != v.Expected.BatchEndpointName { + t.Fatalf("Expected %q but got %q for BatchEndpointName", v.Expected.BatchEndpointName, actual.BatchEndpointName) + } + + if actual.DeploymentName != v.Expected.DeploymentName { + t.Fatalf("Expected %q but got %q for DeploymentName", v.Expected.DeploymentName, actual.DeploymentName) + } + + } +} + +func TestParseDeploymentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DeploymentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/batchEndpoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/bAtChEnDpOiNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/batchEndpoints/batchEndpointName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/bAtChEnDpOiNtS/bAtChEnDpOiNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/batchEndpoints/batchEndpointName/deployments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/bAtChEnDpOiNtS/bAtChEnDpOiNtNaMe/dEpLoYmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/batchEndpoints/batchEndpointName/deployments/deploymentName", + Expected: &DeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + BatchEndpointName: "batchEndpointName", + DeploymentName: "deploymentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/batchEndpoints/batchEndpointName/deployments/deploymentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/bAtChEnDpOiNtS/bAtChEnDpOiNtNaMe/dEpLoYmEnTs/dEpLoYmEnTnAmE", + Expected: &DeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + BatchEndpointName: "bAtChEnDpOiNtNaMe", + DeploymentName: "dEpLoYmEnTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/bAtChEnDpOiNtS/bAtChEnDpOiNtNaMe/dEpLoYmEnTs/dEpLoYmEnTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDeploymentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.BatchEndpointName != v.Expected.BatchEndpointName { + t.Fatalf("Expected %q but got %q for BatchEndpointName", v.Expected.BatchEndpointName, actual.BatchEndpointName) + } + + if actual.DeploymentName != v.Expected.DeploymentName { + t.Fatalf("Expected %q but got %q for DeploymentName", v.Expected.DeploymentName, actual.DeploymentName) + } + + } +} + +func TestSegmentsForDeploymentId(t *testing.T) { + segments := DeploymentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DeploymentId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchdeployment/method_createorupdate.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/method_createorupdate.go new file mode 100644 index 00000000000..498047a26ba --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/method_createorupdate.go @@ -0,0 +1,75 @@ +package batchdeployment + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *BatchDeploymentTrackedResource +} + +// CreateOrUpdate ... +func (c BatchDeploymentClient) CreateOrUpdate(ctx context.Context, id DeploymentId, input BatchDeploymentTrackedResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c BatchDeploymentClient) CreateOrUpdateThenPoll(ctx context.Context, id DeploymentId, input BatchDeploymentTrackedResource) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchdeployment/method_delete.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/method_delete.go new file mode 100644 index 00000000000..087f2460826 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/method_delete.go @@ -0,0 +1,71 @@ +package batchdeployment + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 BatchDeploymentClient) Delete(ctx context.Context, id DeploymentId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c BatchDeploymentClient) DeleteThenPoll(ctx context.Context, id DeploymentId) 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/machinelearningservices/2025-04-01/batchdeployment/method_get.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/method_get.go new file mode 100644 index 00000000000..d1ccbe4ea9c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/method_get.go @@ -0,0 +1,53 @@ +package batchdeployment + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *BatchDeploymentTrackedResource +} + +// Get ... +func (c BatchDeploymentClient) Get(ctx context.Context, id DeploymentId) (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 BatchDeploymentTrackedResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchdeployment/method_list.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/method_list.go new file mode 100644 index 00000000000..13f187a969e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/method_list.go @@ -0,0 +1,142 @@ +package batchdeployment + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]BatchDeploymentTrackedResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []BatchDeploymentTrackedResource +} + +type ListOperationOptions struct { + OrderBy *string + Skip *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.OrderBy != nil { + out.Append("$orderBy", fmt.Sprintf("%v", *o.OrderBy)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c BatchDeploymentClient) List(ctx context.Context, id BatchEndpointId, 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/deployments", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]BatchDeploymentTrackedResource `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 BatchDeploymentClient) ListComplete(ctx context.Context, id BatchEndpointId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, BatchDeploymentTrackedResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BatchDeploymentClient) ListCompleteMatchingPredicate(ctx context.Context, id BatchEndpointId, options ListOperationOptions, predicate BatchDeploymentTrackedResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]BatchDeploymentTrackedResource, 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/machinelearningservices/2025-04-01/batchdeployment/method_update.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/method_update.go new file mode 100644 index 00000000000..3133c9f6aa6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/method_update.go @@ -0,0 +1,75 @@ +package batchdeployment + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *BatchDeploymentTrackedResource +} + +// Update ... +func (c BatchDeploymentClient) Update(ctx context.Context, id DeploymentId, input PartialBatchDeploymentPartialMinimalTrackedResourceWithProperties) (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 BatchDeploymentClient) UpdateThenPoll(ctx context.Context, id DeploymentId, input PartialBatchDeploymentPartialMinimalTrackedResourceWithProperties) 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/machinelearningservices/2025-04-01/batchdeployment/model_assetreferencebase.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_assetreferencebase.go new file mode 100644 index 00000000000..379a277024c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_assetreferencebase.go @@ -0,0 +1,91 @@ +package batchdeployment + +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 AssetReferenceBase interface { + AssetReferenceBase() BaseAssetReferenceBaseImpl +} + +var _ AssetReferenceBase = BaseAssetReferenceBaseImpl{} + +type BaseAssetReferenceBaseImpl struct { + ReferenceType ReferenceType `json:"referenceType"` +} + +func (s BaseAssetReferenceBaseImpl) AssetReferenceBase() BaseAssetReferenceBaseImpl { + return s +} + +var _ AssetReferenceBase = RawAssetReferenceBaseImpl{} + +// RawAssetReferenceBaseImpl 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 RawAssetReferenceBaseImpl struct { + assetReferenceBase BaseAssetReferenceBaseImpl + Type string + Values map[string]interface{} +} + +func (s RawAssetReferenceBaseImpl) AssetReferenceBase() BaseAssetReferenceBaseImpl { + return s.assetReferenceBase +} + +func UnmarshalAssetReferenceBaseImplementation(input []byte) (AssetReferenceBase, 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 AssetReferenceBase into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["referenceType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "DataPath") { + var out DataPathAssetReference + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DataPathAssetReference: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Id") { + var out IdAssetReference + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into IdAssetReference: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "OutputPath") { + var out OutputPathAssetReference + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into OutputPathAssetReference: %+v", err) + } + return out, nil + } + + var parent BaseAssetReferenceBaseImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseAssetReferenceBaseImpl: %+v", err) + } + + return RawAssetReferenceBaseImpl{ + assetReferenceBase: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_batchdeployment.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_batchdeployment.go new file mode 100644 index 00000000000..3f05295876f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_batchdeployment.go @@ -0,0 +1,93 @@ +package batchdeployment + +import ( + "encoding/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 BatchDeployment struct { + CodeConfiguration *CodeConfiguration `json:"codeConfiguration,omitempty"` + Compute *string `json:"compute,omitempty"` + DeploymentConfiguration BatchDeploymentConfiguration `json:"deploymentConfiguration"` + Description *string `json:"description,omitempty"` + EnvironmentId *string `json:"environmentId,omitempty"` + EnvironmentVariables *map[string]string `json:"environmentVariables,omitempty"` + ErrorThreshold *int64 `json:"errorThreshold,omitempty"` + LoggingLevel *BatchLoggingLevel `json:"loggingLevel,omitempty"` + MaxConcurrencyPerInstance *int64 `json:"maxConcurrencyPerInstance,omitempty"` + MiniBatchSize *int64 `json:"miniBatchSize,omitempty"` + Model AssetReferenceBase `json:"model"` + OutputAction *BatchOutputAction `json:"outputAction,omitempty"` + OutputFileName *string `json:"outputFileName,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ProvisioningState *DeploymentProvisioningState `json:"provisioningState,omitempty"` + Resources *ResourceConfiguration `json:"resources,omitempty"` + RetrySettings *BatchRetrySettings `json:"retrySettings,omitempty"` +} + +var _ json.Unmarshaler = &BatchDeployment{} + +func (s *BatchDeployment) UnmarshalJSON(bytes []byte) error { + var decoded struct { + CodeConfiguration *CodeConfiguration `json:"codeConfiguration,omitempty"` + Compute *string `json:"compute,omitempty"` + Description *string `json:"description,omitempty"` + EnvironmentId *string `json:"environmentId,omitempty"` + EnvironmentVariables *map[string]string `json:"environmentVariables,omitempty"` + ErrorThreshold *int64 `json:"errorThreshold,omitempty"` + LoggingLevel *BatchLoggingLevel `json:"loggingLevel,omitempty"` + MaxConcurrencyPerInstance *int64 `json:"maxConcurrencyPerInstance,omitempty"` + MiniBatchSize *int64 `json:"miniBatchSize,omitempty"` + OutputAction *BatchOutputAction `json:"outputAction,omitempty"` + OutputFileName *string `json:"outputFileName,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ProvisioningState *DeploymentProvisioningState `json:"provisioningState,omitempty"` + Resources *ResourceConfiguration `json:"resources,omitempty"` + RetrySettings *BatchRetrySettings `json:"retrySettings,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.CodeConfiguration = decoded.CodeConfiguration + s.Compute = decoded.Compute + s.Description = decoded.Description + s.EnvironmentId = decoded.EnvironmentId + s.EnvironmentVariables = decoded.EnvironmentVariables + s.ErrorThreshold = decoded.ErrorThreshold + s.LoggingLevel = decoded.LoggingLevel + s.MaxConcurrencyPerInstance = decoded.MaxConcurrencyPerInstance + s.MiniBatchSize = decoded.MiniBatchSize + s.OutputAction = decoded.OutputAction + s.OutputFileName = decoded.OutputFileName + s.Properties = decoded.Properties + s.ProvisioningState = decoded.ProvisioningState + s.Resources = decoded.Resources + s.RetrySettings = decoded.RetrySettings + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling BatchDeployment into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["deploymentConfiguration"]; ok { + impl, err := UnmarshalBatchDeploymentConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'DeploymentConfiguration' for 'BatchDeployment': %+v", err) + } + s.DeploymentConfiguration = impl + } + + if v, ok := temp["model"]; ok { + impl, err := UnmarshalAssetReferenceBaseImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Model' for 'BatchDeployment': %+v", err) + } + s.Model = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_batchdeploymentconfiguration.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_batchdeploymentconfiguration.go new file mode 100644 index 00000000000..0e096c383b8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_batchdeploymentconfiguration.go @@ -0,0 +1,75 @@ +package batchdeployment + +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 BatchDeploymentConfiguration interface { + BatchDeploymentConfiguration() BaseBatchDeploymentConfigurationImpl +} + +var _ BatchDeploymentConfiguration = BaseBatchDeploymentConfigurationImpl{} + +type BaseBatchDeploymentConfigurationImpl struct { + DeploymentConfigurationType BatchDeploymentConfigurationType `json:"deploymentConfigurationType"` +} + +func (s BaseBatchDeploymentConfigurationImpl) BatchDeploymentConfiguration() BaseBatchDeploymentConfigurationImpl { + return s +} + +var _ BatchDeploymentConfiguration = RawBatchDeploymentConfigurationImpl{} + +// RawBatchDeploymentConfigurationImpl 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 RawBatchDeploymentConfigurationImpl struct { + batchDeploymentConfiguration BaseBatchDeploymentConfigurationImpl + Type string + Values map[string]interface{} +} + +func (s RawBatchDeploymentConfigurationImpl) BatchDeploymentConfiguration() BaseBatchDeploymentConfigurationImpl { + return s.batchDeploymentConfiguration +} + +func UnmarshalBatchDeploymentConfigurationImplementation(input []byte) (BatchDeploymentConfiguration, 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 BatchDeploymentConfiguration into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["deploymentConfigurationType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "PipelineComponent") { + var out BatchPipelineComponentDeploymentConfiguration + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into BatchPipelineComponentDeploymentConfiguration: %+v", err) + } + return out, nil + } + + var parent BaseBatchDeploymentConfigurationImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseBatchDeploymentConfigurationImpl: %+v", err) + } + + return RawBatchDeploymentConfigurationImpl{ + batchDeploymentConfiguration: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_batchdeploymenttrackedresource.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_batchdeploymenttrackedresource.go new file mode 100644 index 00000000000..47ccfdb4c47 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_batchdeploymenttrackedresource.go @@ -0,0 +1,22 @@ +package batchdeployment + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BatchDeploymentTrackedResource struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties BatchDeployment `json:"properties"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_batchpipelinecomponentdeploymentconfiguration.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_batchpipelinecomponentdeploymentconfiguration.go new file mode 100644 index 00000000000..858e608e4ca --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_batchpipelinecomponentdeploymentconfiguration.go @@ -0,0 +1,53 @@ +package batchdeployment + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ BatchDeploymentConfiguration = BatchPipelineComponentDeploymentConfiguration{} + +type BatchPipelineComponentDeploymentConfiguration struct { + ComponentId *IdAssetReference `json:"componentId,omitempty"` + Description *string `json:"description,omitempty"` + Settings *map[string]string `json:"settings,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + + // Fields inherited from BatchDeploymentConfiguration + + DeploymentConfigurationType BatchDeploymentConfigurationType `json:"deploymentConfigurationType"` +} + +func (s BatchPipelineComponentDeploymentConfiguration) BatchDeploymentConfiguration() BaseBatchDeploymentConfigurationImpl { + return BaseBatchDeploymentConfigurationImpl{ + DeploymentConfigurationType: s.DeploymentConfigurationType, + } +} + +var _ json.Marshaler = BatchPipelineComponentDeploymentConfiguration{} + +func (s BatchPipelineComponentDeploymentConfiguration) MarshalJSON() ([]byte, error) { + type wrapper BatchPipelineComponentDeploymentConfiguration + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling BatchPipelineComponentDeploymentConfiguration: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling BatchPipelineComponentDeploymentConfiguration: %+v", err) + } + + decoded["deploymentConfigurationType"] = "PipelineComponent" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling BatchPipelineComponentDeploymentConfiguration: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_batchretrysettings.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_batchretrysettings.go new file mode 100644 index 00000000000..798513e4784 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_batchretrysettings.go @@ -0,0 +1,9 @@ +package batchdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BatchRetrySettings struct { + MaxRetries *int64 `json:"maxRetries,omitempty"` + Timeout *string `json:"timeout,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_codeconfiguration.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_codeconfiguration.go new file mode 100644 index 00000000000..3f99a6b9259 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_codeconfiguration.go @@ -0,0 +1,9 @@ +package batchdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CodeConfiguration struct { + CodeId *string `json:"codeId,omitempty"` + ScoringScript string `json:"scoringScript"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_datapathassetreference.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_datapathassetreference.go new file mode 100644 index 00000000000..5505b2d3050 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_datapathassetreference.go @@ -0,0 +1,51 @@ +package batchdeployment + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AssetReferenceBase = DataPathAssetReference{} + +type DataPathAssetReference struct { + DatastoreId *string `json:"datastoreId,omitempty"` + Path *string `json:"path,omitempty"` + + // Fields inherited from AssetReferenceBase + + ReferenceType ReferenceType `json:"referenceType"` +} + +func (s DataPathAssetReference) AssetReferenceBase() BaseAssetReferenceBaseImpl { + return BaseAssetReferenceBaseImpl{ + ReferenceType: s.ReferenceType, + } +} + +var _ json.Marshaler = DataPathAssetReference{} + +func (s DataPathAssetReference) MarshalJSON() ([]byte, error) { + type wrapper DataPathAssetReference + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DataPathAssetReference: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DataPathAssetReference: %+v", err) + } + + decoded["referenceType"] = "DataPath" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DataPathAssetReference: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_idassetreference.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_idassetreference.go new file mode 100644 index 00000000000..7b61763dd5e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_idassetreference.go @@ -0,0 +1,50 @@ +package batchdeployment + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AssetReferenceBase = IdAssetReference{} + +type IdAssetReference struct { + AssetId string `json:"assetId"` + + // Fields inherited from AssetReferenceBase + + ReferenceType ReferenceType `json:"referenceType"` +} + +func (s IdAssetReference) AssetReferenceBase() BaseAssetReferenceBaseImpl { + return BaseAssetReferenceBaseImpl{ + ReferenceType: s.ReferenceType, + } +} + +var _ json.Marshaler = IdAssetReference{} + +func (s IdAssetReference) MarshalJSON() ([]byte, error) { + type wrapper IdAssetReference + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling IdAssetReference: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling IdAssetReference: %+v", err) + } + + decoded["referenceType"] = "Id" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling IdAssetReference: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_outputpathassetreference.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_outputpathassetreference.go new file mode 100644 index 00000000000..df0f556e397 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_outputpathassetreference.go @@ -0,0 +1,51 @@ +package batchdeployment + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AssetReferenceBase = OutputPathAssetReference{} + +type OutputPathAssetReference struct { + JobId *string `json:"jobId,omitempty"` + Path *string `json:"path,omitempty"` + + // Fields inherited from AssetReferenceBase + + ReferenceType ReferenceType `json:"referenceType"` +} + +func (s OutputPathAssetReference) AssetReferenceBase() BaseAssetReferenceBaseImpl { + return BaseAssetReferenceBaseImpl{ + ReferenceType: s.ReferenceType, + } +} + +var _ json.Marshaler = OutputPathAssetReference{} + +func (s OutputPathAssetReference) MarshalJSON() ([]byte, error) { + type wrapper OutputPathAssetReference + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling OutputPathAssetReference: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling OutputPathAssetReference: %+v", err) + } + + decoded["referenceType"] = "OutputPath" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling OutputPathAssetReference: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_partialbatchdeployment.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_partialbatchdeployment.go new file mode 100644 index 00000000000..c8f30095dce --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_partialbatchdeployment.go @@ -0,0 +1,8 @@ +package batchdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PartialBatchDeployment struct { + Description *string `json:"description,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_partialbatchdeploymentpartialminimaltrackedresourcewithproperties.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_partialbatchdeploymentpartialminimaltrackedresourcewithproperties.go new file mode 100644 index 00000000000..19faa0acdd6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_partialbatchdeploymentpartialminimaltrackedresourcewithproperties.go @@ -0,0 +1,9 @@ +package batchdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PartialBatchDeploymentPartialMinimalTrackedResourceWithProperties struct { + Properties *PartialBatchDeployment `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_resourceconfiguration.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_resourceconfiguration.go new file mode 100644 index 00000000000..13038cdd991 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_resourceconfiguration.go @@ -0,0 +1,10 @@ +package batchdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceConfiguration struct { + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceType *string `json:"instanceType,omitempty"` + Properties *map[string]interface{} `json:"properties,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_sku.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_sku.go new file mode 100644 index 00000000000..97e4ad7f848 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/model_sku.go @@ -0,0 +1,12 @@ +package batchdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Name string `json:"name"` + Size *string `json:"size,omitempty"` + Tier *SkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchdeployment/predicates.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/predicates.go new file mode 100644 index 00000000000..2c12ee7610f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/predicates.go @@ -0,0 +1,37 @@ +package batchdeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BatchDeploymentTrackedResourceOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p BatchDeploymentTrackedResourceOperationPredicate) Matches(input BatchDeploymentTrackedResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchdeployment/version.go b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/version.go new file mode 100644 index 00000000000..4030292da44 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchdeployment/version.go @@ -0,0 +1,10 @@ +package batchdeployment + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/batchdeployment/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchendpoint/README.md b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/README.md new file mode 100644 index 00000000000..d0ae6ae2de5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/README.md @@ -0,0 +1,115 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/batchendpoint` Documentation + +The `batchendpoint` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/batchendpoint" +``` + + +### Client Initialization + +```go +client := batchendpoint.NewBatchEndpointClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `BatchEndpointClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := batchendpoint.NewBatchEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "batchEndpointName") + +payload := batchendpoint.BatchEndpointTrackedResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `BatchEndpointClient.Delete` + +```go +ctx := context.TODO() +id := batchendpoint.NewBatchEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "batchEndpointName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `BatchEndpointClient.Get` + +```go +ctx := context.TODO() +id := batchendpoint.NewBatchEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "batchEndpointName") + +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: `BatchEndpointClient.List` + +```go +ctx := context.TODO() +id := batchendpoint.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +// alternatively `client.List(ctx, id, batchendpoint.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, batchendpoint.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `BatchEndpointClient.ListKeys` + +```go +ctx := context.TODO() +id := batchendpoint.NewBatchEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "batchEndpointName") + +read, err := client.ListKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `BatchEndpointClient.Update` + +```go +ctx := context.TODO() +id := batchendpoint.NewBatchEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "batchEndpointName") + +payload := batchendpoint.PartialMinimalTrackedResourceWithIdentity{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/batchendpoint/client.go b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/client.go new file mode 100644 index 00000000000..936dcc31960 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/client.go @@ -0,0 +1,26 @@ +package batchendpoint + +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 BatchEndpointClient struct { + Client *resourcemanager.Client +} + +func NewBatchEndpointClientWithBaseURI(sdkApi sdkEnv.Api) (*BatchEndpointClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "batchendpoint", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating BatchEndpointClient: %+v", err) + } + + return &BatchEndpointClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchendpoint/constants.go b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/constants.go new file mode 100644 index 00000000000..de68642cf38 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/constants.go @@ -0,0 +1,201 @@ +package batchendpoint + +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 EndpointAuthMode string + +const ( + EndpointAuthModeAADToken EndpointAuthMode = "AADToken" + EndpointAuthModeAMLToken EndpointAuthMode = "AMLToken" + EndpointAuthModeKey EndpointAuthMode = "Key" +) + +func PossibleValuesForEndpointAuthMode() []string { + return []string{ + string(EndpointAuthModeAADToken), + string(EndpointAuthModeAMLToken), + string(EndpointAuthModeKey), + } +} + +func (s *EndpointAuthMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEndpointAuthMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEndpointAuthMode(input string) (*EndpointAuthMode, error) { + vals := map[string]EndpointAuthMode{ + "aadtoken": EndpointAuthModeAADToken, + "amltoken": EndpointAuthModeAMLToken, + "key": EndpointAuthModeKey, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EndpointAuthMode(input) + return &out, nil +} + +type EndpointProvisioningState string + +const ( + EndpointProvisioningStateCanceled EndpointProvisioningState = "Canceled" + EndpointProvisioningStateCreating EndpointProvisioningState = "Creating" + EndpointProvisioningStateDeleting EndpointProvisioningState = "Deleting" + EndpointProvisioningStateFailed EndpointProvisioningState = "Failed" + EndpointProvisioningStateSucceeded EndpointProvisioningState = "Succeeded" + EndpointProvisioningStateUpdating EndpointProvisioningState = "Updating" +) + +func PossibleValuesForEndpointProvisioningState() []string { + return []string{ + string(EndpointProvisioningStateCanceled), + string(EndpointProvisioningStateCreating), + string(EndpointProvisioningStateDeleting), + string(EndpointProvisioningStateFailed), + string(EndpointProvisioningStateSucceeded), + string(EndpointProvisioningStateUpdating), + } +} + +func (s *EndpointProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEndpointProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEndpointProvisioningState(input string) (*EndpointProvisioningState, error) { + vals := map[string]EndpointProvisioningState{ + "canceled": EndpointProvisioningStateCanceled, + "creating": EndpointProvisioningStateCreating, + "deleting": EndpointProvisioningStateDeleting, + "failed": EndpointProvisioningStateFailed, + "succeeded": EndpointProvisioningStateSucceeded, + "updating": EndpointProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EndpointProvisioningState(input) + return &out, nil +} + +type ManagedServiceIdentityType string + +const ( + ManagedServiceIdentityTypeNone ManagedServiceIdentityType = "None" + ManagedServiceIdentityTypeSystemAssigned ManagedServiceIdentityType = "SystemAssigned" + ManagedServiceIdentityTypeSystemAssignedUserAssigned ManagedServiceIdentityType = "SystemAssigned,UserAssigned" + ManagedServiceIdentityTypeUserAssigned ManagedServiceIdentityType = "UserAssigned" +) + +func PossibleValuesForManagedServiceIdentityType() []string { + return []string{ + string(ManagedServiceIdentityTypeNone), + string(ManagedServiceIdentityTypeSystemAssigned), + string(ManagedServiceIdentityTypeSystemAssignedUserAssigned), + string(ManagedServiceIdentityTypeUserAssigned), + } +} + +func (s *ManagedServiceIdentityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedServiceIdentityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedServiceIdentityType(input string) (*ManagedServiceIdentityType, error) { + vals := map[string]ManagedServiceIdentityType{ + "none": ManagedServiceIdentityTypeNone, + "systemassigned": ManagedServiceIdentityTypeSystemAssigned, + "systemassigned,userassigned": ManagedServiceIdentityTypeSystemAssignedUserAssigned, + "userassigned": ManagedServiceIdentityTypeUserAssigned, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedServiceIdentityType(input) + return &out, nil +} + +type SkuTier string + +const ( + SkuTierBasic SkuTier = "Basic" + SkuTierFree SkuTier = "Free" + SkuTierPremium SkuTier = "Premium" + SkuTierStandard SkuTier = "Standard" +) + +func PossibleValuesForSkuTier() []string { + return []string{ + string(SkuTierBasic), + string(SkuTierFree), + string(SkuTierPremium), + string(SkuTierStandard), + } +} + +func (s *SkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuTier(input string) (*SkuTier, error) { + vals := map[string]SkuTier{ + "basic": SkuTierBasic, + "free": SkuTierFree, + "premium": SkuTierPremium, + "standard": SkuTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuTier(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchendpoint/id_batchendpoint.go b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/id_batchendpoint.go new file mode 100644 index 00000000000..1f4b1aeaee8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/id_batchendpoint.go @@ -0,0 +1,139 @@ +package batchendpoint + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&BatchEndpointId{}) +} + +var _ resourceids.ResourceId = &BatchEndpointId{} + +// BatchEndpointId is a struct representing the Resource ID for a Batch Endpoint +type BatchEndpointId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + BatchEndpointName string +} + +// NewBatchEndpointID returns a new BatchEndpointId struct +func NewBatchEndpointID(subscriptionId string, resourceGroupName string, workspaceName string, batchEndpointName string) BatchEndpointId { + return BatchEndpointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + BatchEndpointName: batchEndpointName, + } +} + +// ParseBatchEndpointID parses 'input' into a BatchEndpointId +func ParseBatchEndpointID(input string) (*BatchEndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&BatchEndpointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BatchEndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseBatchEndpointIDInsensitively parses 'input' case-insensitively into a BatchEndpointId +// note: this method should only be used for API response data and not user input +func ParseBatchEndpointIDInsensitively(input string) (*BatchEndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&BatchEndpointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := BatchEndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *BatchEndpointId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.BatchEndpointName, ok = input.Parsed["batchEndpointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "batchEndpointName", input) + } + + return nil +} + +// ValidateBatchEndpointID checks that 'input' can be parsed as a Batch Endpoint ID +func ValidateBatchEndpointID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseBatchEndpointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Batch Endpoint ID +func (id BatchEndpointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/batchEndpoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.BatchEndpointName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Batch Endpoint ID +func (id BatchEndpointId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticBatchEndpoints", "batchEndpoints", "batchEndpoints"), + resourceids.UserSpecifiedSegment("batchEndpointName", "batchEndpointName"), + } +} + +// String returns a human-readable description of this Batch Endpoint ID +func (id BatchEndpointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Batch Endpoint Name: %q", id.BatchEndpointName), + } + return fmt.Sprintf("Batch Endpoint (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchendpoint/id_batchendpoint_test.go b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/id_batchendpoint_test.go new file mode 100644 index 00000000000..35647bc9baa --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/id_batchendpoint_test.go @@ -0,0 +1,327 @@ +package batchendpoint + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &BatchEndpointId{} + +func TestNewBatchEndpointID(t *testing.T) { + id := NewBatchEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "batchEndpointName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.BatchEndpointName != "batchEndpointName" { + t.Fatalf("Expected %q but got %q for Segment 'BatchEndpointName'", id.BatchEndpointName, "batchEndpointName") + } +} + +func TestFormatBatchEndpointID(t *testing.T) { + actual := NewBatchEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "batchEndpointName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/batchEndpoints/batchEndpointName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseBatchEndpointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BatchEndpointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/batchEndpoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/batchEndpoints/batchEndpointName", + Expected: &BatchEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + BatchEndpointName: "batchEndpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/batchEndpoints/batchEndpointName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBatchEndpointID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.BatchEndpointName != v.Expected.BatchEndpointName { + t.Fatalf("Expected %q but got %q for BatchEndpointName", v.Expected.BatchEndpointName, actual.BatchEndpointName) + } + + } +} + +func TestParseBatchEndpointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *BatchEndpointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/batchEndpoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/bAtChEnDpOiNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/batchEndpoints/batchEndpointName", + Expected: &BatchEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + BatchEndpointName: "batchEndpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/batchEndpoints/batchEndpointName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/bAtChEnDpOiNtS/bAtChEnDpOiNtNaMe", + Expected: &BatchEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + BatchEndpointName: "bAtChEnDpOiNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/bAtChEnDpOiNtS/bAtChEnDpOiNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseBatchEndpointIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.BatchEndpointName != v.Expected.BatchEndpointName { + t.Fatalf("Expected %q but got %q for BatchEndpointName", v.Expected.BatchEndpointName, actual.BatchEndpointName) + } + + } +} + +func TestSegmentsForBatchEndpointId(t *testing.T) { + segments := BatchEndpointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("BatchEndpointId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchendpoint/id_workspace.go b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/id_workspace.go new file mode 100644 index 00000000000..b3a7a4cf2de --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/id_workspace.go @@ -0,0 +1,130 @@ +package batchendpoint + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchendpoint/id_workspace_test.go b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/id_workspace_test.go new file mode 100644 index 00000000000..ebe8703680c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/id_workspace_test.go @@ -0,0 +1,282 @@ +package batchendpoint + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchendpoint/method_createorupdate.go b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/method_createorupdate.go new file mode 100644 index 00000000000..256b5b9d437 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/method_createorupdate.go @@ -0,0 +1,75 @@ +package batchendpoint + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *BatchEndpointTrackedResource +} + +// CreateOrUpdate ... +func (c BatchEndpointClient) CreateOrUpdate(ctx context.Context, id BatchEndpointId, input BatchEndpointTrackedResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c BatchEndpointClient) CreateOrUpdateThenPoll(ctx context.Context, id BatchEndpointId, input BatchEndpointTrackedResource) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchendpoint/method_delete.go b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/method_delete.go new file mode 100644 index 00000000000..124e0b67168 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/method_delete.go @@ -0,0 +1,71 @@ +package batchendpoint + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 BatchEndpointClient) Delete(ctx context.Context, id BatchEndpointId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c BatchEndpointClient) DeleteThenPoll(ctx context.Context, id BatchEndpointId) 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/machinelearningservices/2025-04-01/batchendpoint/method_get.go b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/method_get.go new file mode 100644 index 00000000000..db6700bbc75 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/method_get.go @@ -0,0 +1,53 @@ +package batchendpoint + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *BatchEndpointTrackedResource +} + +// Get ... +func (c BatchEndpointClient) Get(ctx context.Context, id BatchEndpointId) (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 BatchEndpointTrackedResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchendpoint/method_list.go b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/method_list.go new file mode 100644 index 00000000000..5f8626cb8bd --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/method_list.go @@ -0,0 +1,138 @@ +package batchendpoint + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]BatchEndpointTrackedResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []BatchEndpointTrackedResource +} + +type ListOperationOptions struct { + Count *int64 + Skip *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.Count != nil { + out.Append("count", fmt.Sprintf("%v", *o.Count)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + 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 BatchEndpointClient) List(ctx context.Context, id WorkspaceId, 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/batchEndpoints", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]BatchEndpointTrackedResource `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 BatchEndpointClient) ListComplete(ctx context.Context, id WorkspaceId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, BatchEndpointTrackedResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c BatchEndpointClient) ListCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, options ListOperationOptions, predicate BatchEndpointTrackedResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]BatchEndpointTrackedResource, 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/machinelearningservices/2025-04-01/batchendpoint/method_listkeys.go b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/method_listkeys.go new file mode 100644 index 00000000000..1a1eec8dfdf --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/method_listkeys.go @@ -0,0 +1,54 @@ +package batchendpoint + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *EndpointAuthKeys +} + +// ListKeys ... +func (c BatchEndpointClient) ListKeys(ctx context.Context, id BatchEndpointId) (result ListKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model EndpointAuthKeys + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchendpoint/method_update.go b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/method_update.go new file mode 100644 index 00000000000..905a3103c49 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/method_update.go @@ -0,0 +1,75 @@ +package batchendpoint + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *BatchEndpointTrackedResource +} + +// Update ... +func (c BatchEndpointClient) Update(ctx context.Context, id BatchEndpointId, input PartialMinimalTrackedResourceWithIdentity) (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 BatchEndpointClient) UpdateThenPoll(ctx context.Context, id BatchEndpointId, input PartialMinimalTrackedResourceWithIdentity) 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/machinelearningservices/2025-04-01/batchendpoint/model_batchendpoint.go b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/model_batchendpoint.go new file mode 100644 index 00000000000..22f8ee28fe5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/model_batchendpoint.go @@ -0,0 +1,15 @@ +package batchendpoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BatchEndpoint struct { + AuthMode EndpointAuthMode `json:"authMode"` + Defaults *BatchEndpointDefaults `json:"defaults,omitempty"` + Description *string `json:"description,omitempty"` + Keys *EndpointAuthKeys `json:"keys,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ProvisioningState *EndpointProvisioningState `json:"provisioningState,omitempty"` + ScoringUri *string `json:"scoringUri,omitempty"` + SwaggerUri *string `json:"swaggerUri,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchendpoint/model_batchendpointdefaults.go b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/model_batchendpointdefaults.go new file mode 100644 index 00000000000..48a8b289319 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/model_batchendpointdefaults.go @@ -0,0 +1,8 @@ +package batchendpoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BatchEndpointDefaults struct { + DeploymentName *string `json:"deploymentName,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchendpoint/model_batchendpointtrackedresource.go b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/model_batchendpointtrackedresource.go new file mode 100644 index 00000000000..b67f17d9313 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/model_batchendpointtrackedresource.go @@ -0,0 +1,22 @@ +package batchendpoint + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BatchEndpointTrackedResource struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties BatchEndpoint `json:"properties"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchendpoint/model_endpointauthkeys.go b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/model_endpointauthkeys.go new file mode 100644 index 00000000000..25294cbcf69 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/model_endpointauthkeys.go @@ -0,0 +1,9 @@ +package batchendpoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointAuthKeys struct { + PrimaryKey *string `json:"primaryKey,omitempty"` + SecondaryKey *string `json:"secondaryKey,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchendpoint/model_partialmanagedserviceidentity.go b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/model_partialmanagedserviceidentity.go new file mode 100644 index 00000000000..ed74ad8b148 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/model_partialmanagedserviceidentity.go @@ -0,0 +1,9 @@ +package batchendpoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PartialManagedServiceIdentity struct { + Type *ManagedServiceIdentityType `json:"type,omitempty"` + UserAssignedIdentities *map[string]interface{} `json:"userAssignedIdentities,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchendpoint/model_partialminimaltrackedresourcewithidentity.go b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/model_partialminimaltrackedresourcewithidentity.go new file mode 100644 index 00000000000..dc9f3215afb --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/model_partialminimaltrackedresourcewithidentity.go @@ -0,0 +1,9 @@ +package batchendpoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PartialMinimalTrackedResourceWithIdentity struct { + Identity *PartialManagedServiceIdentity `json:"identity,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchendpoint/model_sku.go b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/model_sku.go new file mode 100644 index 00000000000..15e452df5eb --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/model_sku.go @@ -0,0 +1,12 @@ +package batchendpoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Name string `json:"name"` + Size *string `json:"size,omitempty"` + Tier *SkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchendpoint/predicates.go b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/predicates.go new file mode 100644 index 00000000000..be868007df0 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/predicates.go @@ -0,0 +1,37 @@ +package batchendpoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BatchEndpointTrackedResourceOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p BatchEndpointTrackedResourceOperationPredicate) Matches(input BatchEndpointTrackedResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/machinelearningservices/2025-04-01/batchendpoint/version.go b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/version.go new file mode 100644 index 00000000000..e35c5e4d37b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/batchendpoint/version.go @@ -0,0 +1,10 @@ +package batchendpoint + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/batchendpoint/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/client.go b/resource-manager/machinelearningservices/2025-04-01/client.go new file mode 100644 index 00000000000..0f3850be8cf --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/client.go @@ -0,0 +1,379 @@ +package v2025_04_01 + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +import ( + "fmt" + + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/batchdeployment" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/batchendpoint" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/codecontainer" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/codeversion" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/componentcontainer" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/componentversion" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/datacontainer" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/datareference" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/datastore" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/dataversion" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/dataversionregistry" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/environmentcontainer" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/environmentversion" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/feature" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/featuresetversion" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/job" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/managednetwork" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/modelcontainer" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/modelversion" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/onlinedeployment" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/onlineendpoint" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/proxyoperations" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/quota" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/registrymanagement" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/schedule" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/workspaces" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + sdkEnv "github.com/hashicorp/go-azure-sdk/sdk/environments" +) + +type Client struct { + BatchDeployment *batchdeployment.BatchDeploymentClient + BatchEndpoint *batchendpoint.BatchEndpointClient + CodeContainer *codecontainer.CodeContainerClient + CodeVersion *codeversion.CodeVersionClient + ComponentContainer *componentcontainer.ComponentContainerClient + ComponentVersion *componentversion.ComponentVersionClient + DataContainer *datacontainer.DataContainerClient + DataContainerRegistry *datacontainerregistry.DataContainerRegistryClient + DataReference *datareference.DataReferenceClient + DataVersion *dataversion.DataVersionClient + DataVersionRegistry *dataversionregistry.DataVersionRegistryClient + Datastore *datastore.DatastoreClient + EnvironmentContainer *environmentcontainer.EnvironmentContainerClient + EnvironmentVersion *environmentversion.EnvironmentVersionClient + Feature *feature.FeatureClient + FeaturesetContainer *featuresetcontainer.FeaturesetContainerClient + FeaturesetVersion *featuresetversion.FeaturesetVersionClient + FeaturestoreEntityContainer *featurestoreentitycontainer.FeaturestoreEntityContainerClient + FeaturestoreEntityVersion *featurestoreentityversion.FeaturestoreEntityVersionClient + Job *job.JobClient + MachineLearningComputes *machinelearningcomputes.MachineLearningComputesClient + ManagedNetwork *managednetwork.ManagedNetworkClient + MarketplaceSubscription *marketplacesubscription.MarketplaceSubscriptionClient + ModelContainer *modelcontainer.ModelContainerClient + ModelVersion *modelversion.ModelVersionClient + OnlineDeployment *onlinedeployment.OnlineDeploymentClient + OnlineEndpoint *onlineendpoint.OnlineEndpointClient + OperationalizationClusters *operationalizationclusters.OperationalizationClustersClient + OutboundNetworkDependenciesEndpoints *outboundnetworkdependenciesendpoints.OutboundNetworkDependenciesEndpointsClient + PrivateEndpointConnections *privateendpointconnections.PrivateEndpointConnectionsClient + ProxyOperations *proxyoperations.ProxyOperationsClient + Quota *quota.QuotaClient + RegistryManagement *registrymanagement.RegistryManagementClient + Schedule *schedule.ScheduleClient + ServerlessEndpoint *serverlessendpoint.ServerlessEndpointClient + V2WorkspaceConnectionResource *v2workspaceconnectionresource.V2WorkspaceConnectionResourceClient + VirtualMachineSizes *virtualmachinesizes.VirtualMachineSizesClient + WorkspacePrivateEndpointConnections *workspaceprivateendpointconnections.WorkspacePrivateEndpointConnectionsClient + WorkspacePrivateLinkResources *workspaceprivatelinkresources.WorkspacePrivateLinkResourcesClient + Workspaces *workspaces.WorkspacesClient +} + +func NewClientWithBaseURI(sdkApi sdkEnv.Api, configureFunc func(c *resourcemanager.Client)) (*Client, error) { + batchDeploymentClient, err := batchdeployment.NewBatchDeploymentClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building BatchDeployment client: %+v", err) + } + configureFunc(batchDeploymentClient.Client) + + batchEndpointClient, err := batchendpoint.NewBatchEndpointClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building BatchEndpoint client: %+v", err) + } + configureFunc(batchEndpointClient.Client) + + codeContainerClient, err := codecontainer.NewCodeContainerClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CodeContainer client: %+v", err) + } + configureFunc(codeContainerClient.Client) + + codeVersionClient, err := codeversion.NewCodeVersionClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building CodeVersion client: %+v", err) + } + configureFunc(codeVersionClient.Client) + + componentContainerClient, err := componentcontainer.NewComponentContainerClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ComponentContainer client: %+v", err) + } + configureFunc(componentContainerClient.Client) + + componentVersionClient, err := componentversion.NewComponentVersionClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ComponentVersion client: %+v", err) + } + configureFunc(componentVersionClient.Client) + + dataContainerClient, err := datacontainer.NewDataContainerClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DataContainer client: %+v", err) + } + configureFunc(dataContainerClient.Client) + + dataContainerRegistryClient, err := datacontainerregistry.NewDataContainerRegistryClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DataContainerRegistry client: %+v", err) + } + configureFunc(dataContainerRegistryClient.Client) + + dataReferenceClient, err := datareference.NewDataReferenceClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DataReference client: %+v", err) + } + configureFunc(dataReferenceClient.Client) + + dataVersionClient, err := dataversion.NewDataVersionClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DataVersion client: %+v", err) + } + configureFunc(dataVersionClient.Client) + + dataVersionRegistryClient, err := dataversionregistry.NewDataVersionRegistryClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building DataVersionRegistry client: %+v", err) + } + configureFunc(dataVersionRegistryClient.Client) + + datastoreClient, err := datastore.NewDatastoreClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Datastore client: %+v", err) + } + configureFunc(datastoreClient.Client) + + environmentContainerClient, err := environmentcontainer.NewEnvironmentContainerClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building EnvironmentContainer client: %+v", err) + } + configureFunc(environmentContainerClient.Client) + + environmentVersionClient, err := environmentversion.NewEnvironmentVersionClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building EnvironmentVersion client: %+v", err) + } + configureFunc(environmentVersionClient.Client) + + featureClient, err := feature.NewFeatureClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Feature client: %+v", err) + } + configureFunc(featureClient.Client) + + featuresetContainerClient, err := featuresetcontainer.NewFeaturesetContainerClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building FeaturesetContainer client: %+v", err) + } + configureFunc(featuresetContainerClient.Client) + + featuresetVersionClient, err := featuresetversion.NewFeaturesetVersionClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building FeaturesetVersion client: %+v", err) + } + configureFunc(featuresetVersionClient.Client) + + featurestoreEntityContainerClient, err := featurestoreentitycontainer.NewFeaturestoreEntityContainerClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building FeaturestoreEntityContainer client: %+v", err) + } + configureFunc(featurestoreEntityContainerClient.Client) + + featurestoreEntityVersionClient, err := featurestoreentityversion.NewFeaturestoreEntityVersionClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building FeaturestoreEntityVersion client: %+v", err) + } + configureFunc(featurestoreEntityVersionClient.Client) + + jobClient, err := job.NewJobClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Job client: %+v", err) + } + configureFunc(jobClient.Client) + + machineLearningComputesClient, err := machinelearningcomputes.NewMachineLearningComputesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building MachineLearningComputes client: %+v", err) + } + configureFunc(machineLearningComputesClient.Client) + + managedNetworkClient, err := managednetwork.NewManagedNetworkClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ManagedNetwork client: %+v", err) + } + configureFunc(managedNetworkClient.Client) + + marketplaceSubscriptionClient, err := marketplacesubscription.NewMarketplaceSubscriptionClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building MarketplaceSubscription client: %+v", err) + } + configureFunc(marketplaceSubscriptionClient.Client) + + modelContainerClient, err := modelcontainer.NewModelContainerClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ModelContainer client: %+v", err) + } + configureFunc(modelContainerClient.Client) + + modelVersionClient, err := modelversion.NewModelVersionClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ModelVersion client: %+v", err) + } + configureFunc(modelVersionClient.Client) + + onlineDeploymentClient, err := onlinedeployment.NewOnlineDeploymentClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building OnlineDeployment client: %+v", err) + } + configureFunc(onlineDeploymentClient.Client) + + onlineEndpointClient, err := onlineendpoint.NewOnlineEndpointClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building OnlineEndpoint client: %+v", err) + } + configureFunc(onlineEndpointClient.Client) + + operationalizationClustersClient, err := operationalizationclusters.NewOperationalizationClustersClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building OperationalizationClusters client: %+v", err) + } + configureFunc(operationalizationClustersClient.Client) + + outboundNetworkDependenciesEndpointsClient, err := outboundnetworkdependenciesendpoints.NewOutboundNetworkDependenciesEndpointsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building OutboundNetworkDependenciesEndpoints client: %+v", err) + } + configureFunc(outboundNetworkDependenciesEndpointsClient.Client) + + privateEndpointConnectionsClient, err := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building PrivateEndpointConnections client: %+v", err) + } + configureFunc(privateEndpointConnectionsClient.Client) + + proxyOperationsClient, err := proxyoperations.NewProxyOperationsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ProxyOperations client: %+v", err) + } + configureFunc(proxyOperationsClient.Client) + + quotaClient, err := quota.NewQuotaClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Quota client: %+v", err) + } + configureFunc(quotaClient.Client) + + registryManagementClient, err := registrymanagement.NewRegistryManagementClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building RegistryManagement client: %+v", err) + } + configureFunc(registryManagementClient.Client) + + scheduleClient, err := schedule.NewScheduleClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Schedule client: %+v", err) + } + configureFunc(scheduleClient.Client) + + serverlessEndpointClient, err := serverlessendpoint.NewServerlessEndpointClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building ServerlessEndpoint client: %+v", err) + } + configureFunc(serverlessEndpointClient.Client) + + v2WorkspaceConnectionResourceClient, err := v2workspaceconnectionresource.NewV2WorkspaceConnectionResourceClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building V2WorkspaceConnectionResource client: %+v", err) + } + configureFunc(v2WorkspaceConnectionResourceClient.Client) + + virtualMachineSizesClient, err := virtualmachinesizes.NewVirtualMachineSizesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building VirtualMachineSizes client: %+v", err) + } + configureFunc(virtualMachineSizesClient.Client) + + workspacePrivateEndpointConnectionsClient, err := workspaceprivateendpointconnections.NewWorkspacePrivateEndpointConnectionsClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building WorkspacePrivateEndpointConnections client: %+v", err) + } + configureFunc(workspacePrivateEndpointConnectionsClient.Client) + + workspacePrivateLinkResourcesClient, err := workspaceprivatelinkresources.NewWorkspacePrivateLinkResourcesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building WorkspacePrivateLinkResources client: %+v", err) + } + configureFunc(workspacePrivateLinkResourcesClient.Client) + + workspacesClient, err := workspaces.NewWorkspacesClientWithBaseURI(sdkApi) + if err != nil { + return nil, fmt.Errorf("building Workspaces client: %+v", err) + } + configureFunc(workspacesClient.Client) + + return &Client{ + BatchDeployment: batchDeploymentClient, + BatchEndpoint: batchEndpointClient, + CodeContainer: codeContainerClient, + CodeVersion: codeVersionClient, + ComponentContainer: componentContainerClient, + ComponentVersion: componentVersionClient, + DataContainer: dataContainerClient, + DataContainerRegistry: dataContainerRegistryClient, + DataReference: dataReferenceClient, + DataVersion: dataVersionClient, + DataVersionRegistry: dataVersionRegistryClient, + Datastore: datastoreClient, + EnvironmentContainer: environmentContainerClient, + EnvironmentVersion: environmentVersionClient, + Feature: featureClient, + FeaturesetContainer: featuresetContainerClient, + FeaturesetVersion: featuresetVersionClient, + FeaturestoreEntityContainer: featurestoreEntityContainerClient, + FeaturestoreEntityVersion: featurestoreEntityVersionClient, + Job: jobClient, + MachineLearningComputes: machineLearningComputesClient, + ManagedNetwork: managedNetworkClient, + MarketplaceSubscription: marketplaceSubscriptionClient, + ModelContainer: modelContainerClient, + ModelVersion: modelVersionClient, + OnlineDeployment: onlineDeploymentClient, + OnlineEndpoint: onlineEndpointClient, + OperationalizationClusters: operationalizationClustersClient, + OutboundNetworkDependenciesEndpoints: outboundNetworkDependenciesEndpointsClient, + PrivateEndpointConnections: privateEndpointConnectionsClient, + ProxyOperations: proxyOperationsClient, + Quota: quotaClient, + RegistryManagement: registryManagementClient, + Schedule: scheduleClient, + ServerlessEndpoint: serverlessEndpointClient, + V2WorkspaceConnectionResource: v2WorkspaceConnectionResourceClient, + VirtualMachineSizes: virtualMachineSizesClient, + WorkspacePrivateEndpointConnections: workspacePrivateEndpointConnectionsClient, + WorkspacePrivateLinkResources: workspacePrivateLinkResourcesClient, + Workspaces: workspacesClient, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codecontainer/README.md b/resource-manager/machinelearningservices/2025-04-01/codecontainer/README.md new file mode 100644 index 00000000000..16394d80ca8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codecontainer/README.md @@ -0,0 +1,152 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/codecontainer` Documentation + +The `codecontainer` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/codecontainer" +``` + + +### Client Initialization + +```go +client := codecontainer.NewCodeContainerClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CodeContainerClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := codecontainer.NewCodeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "codeName") + +payload := codecontainer.CodeContainerResource{ + // ... +} + + +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: `CodeContainerClient.Delete` + +```go +ctx := context.TODO() +id := codecontainer.NewCodeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "codeName") + +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: `CodeContainerClient.Get` + +```go +ctx := context.TODO() +id := codecontainer.NewCodeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "codeName") + +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: `CodeContainerClient.List` + +```go +ctx := context.TODO() +id := codecontainer.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +// alternatively `client.List(ctx, id, codecontainer.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, codecontainer.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CodeContainerClient.RegistryCodeContainersCreateOrUpdate` + +```go +ctx := context.TODO() +id := codecontainer.NewRegistryCodeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "codeName") + +payload := codecontainer.CodeContainerResource{ + // ... +} + + +if err := client.RegistryCodeContainersCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CodeContainerClient.RegistryCodeContainersDelete` + +```go +ctx := context.TODO() +id := codecontainer.NewRegistryCodeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "codeName") + +if err := client.RegistryCodeContainersDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CodeContainerClient.RegistryCodeContainersGet` + +```go +ctx := context.TODO() +id := codecontainer.NewRegistryCodeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "codeName") + +read, err := client.RegistryCodeContainersGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CodeContainerClient.RegistryCodeContainersList` + +```go +ctx := context.TODO() +id := codecontainer.NewRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName") + +// alternatively `client.RegistryCodeContainersList(ctx, id, codecontainer.DefaultRegistryCodeContainersListOperationOptions())` can be used to do batched pagination +items, err := client.RegistryCodeContainersListComplete(ctx, id, codecontainer.DefaultRegistryCodeContainersListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/codecontainer/client.go b/resource-manager/machinelearningservices/2025-04-01/codecontainer/client.go new file mode 100644 index 00000000000..757f7bbcf04 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codecontainer/client.go @@ -0,0 +1,26 @@ +package codecontainer + +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 CodeContainerClient struct { + Client *resourcemanager.Client +} + +func NewCodeContainerClientWithBaseURI(sdkApi sdkEnv.Api) (*CodeContainerClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "codecontainer", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CodeContainerClient: %+v", err) + } + + return &CodeContainerClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codecontainer/constants.go b/resource-manager/machinelearningservices/2025-04-01/codecontainer/constants.go new file mode 100644 index 00000000000..cfd558c99db --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codecontainer/constants.go @@ -0,0 +1,63 @@ +package codecontainer + +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 AssetProvisioningState string + +const ( + AssetProvisioningStateCanceled AssetProvisioningState = "Canceled" + AssetProvisioningStateCreating AssetProvisioningState = "Creating" + AssetProvisioningStateDeleting AssetProvisioningState = "Deleting" + AssetProvisioningStateFailed AssetProvisioningState = "Failed" + AssetProvisioningStateSucceeded AssetProvisioningState = "Succeeded" + AssetProvisioningStateUpdating AssetProvisioningState = "Updating" +) + +func PossibleValuesForAssetProvisioningState() []string { + return []string{ + string(AssetProvisioningStateCanceled), + string(AssetProvisioningStateCreating), + string(AssetProvisioningStateDeleting), + string(AssetProvisioningStateFailed), + string(AssetProvisioningStateSucceeded), + string(AssetProvisioningStateUpdating), + } +} + +func (s *AssetProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAssetProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAssetProvisioningState(input string) (*AssetProvisioningState, error) { + vals := map[string]AssetProvisioningState{ + "canceled": AssetProvisioningStateCanceled, + "creating": AssetProvisioningStateCreating, + "deleting": AssetProvisioningStateDeleting, + "failed": AssetProvisioningStateFailed, + "succeeded": AssetProvisioningStateSucceeded, + "updating": AssetProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AssetProvisioningState(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codecontainer/id_code.go b/resource-manager/machinelearningservices/2025-04-01/codecontainer/id_code.go new file mode 100644 index 00000000000..c833044c6f5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codecontainer/id_code.go @@ -0,0 +1,139 @@ +package codecontainer + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CodeId{}) +} + +var _ resourceids.ResourceId = &CodeId{} + +// CodeId is a struct representing the Resource ID for a Code +type CodeId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + CodeName string +} + +// NewCodeID returns a new CodeId struct +func NewCodeID(subscriptionId string, resourceGroupName string, workspaceName string, codeName string) CodeId { + return CodeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + CodeName: codeName, + } +} + +// ParseCodeID parses 'input' into a CodeId +func ParseCodeID(input string) (*CodeId, error) { + parser := resourceids.NewParserFromResourceIdType(&CodeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CodeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCodeIDInsensitively parses 'input' case-insensitively into a CodeId +// note: this method should only be used for API response data and not user input +func ParseCodeIDInsensitively(input string) (*CodeId, error) { + parser := resourceids.NewParserFromResourceIdType(&CodeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CodeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CodeId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.CodeName, ok = input.Parsed["codeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "codeName", input) + } + + return nil +} + +// ValidateCodeID checks that 'input' can be parsed as a Code ID +func ValidateCodeID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCodeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Code ID +func (id CodeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/codes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.CodeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Code ID +func (id CodeId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticCodes", "codes", "codes"), + resourceids.UserSpecifiedSegment("codeName", "codeName"), + } +} + +// String returns a human-readable description of this Code ID +func (id CodeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Code Name: %q", id.CodeName), + } + return fmt.Sprintf("Code (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codecontainer/id_code_test.go b/resource-manager/machinelearningservices/2025-04-01/codecontainer/id_code_test.go new file mode 100644 index 00000000000..4dca6bc0255 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codecontainer/id_code_test.go @@ -0,0 +1,327 @@ +package codecontainer + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CodeId{} + +func TestNewCodeID(t *testing.T) { + id := NewCodeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "codeName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.CodeName != "codeName" { + t.Fatalf("Expected %q but got %q for Segment 'CodeName'", id.CodeName, "codeName") + } +} + +func TestFormatCodeID(t *testing.T) { + actual := NewCodeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "codeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/codes/codeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCodeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CodeId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/codes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/codes/codeName", + Expected: &CodeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + CodeName: "codeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/codes/codeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCodeID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.CodeName != v.Expected.CodeName { + t.Fatalf("Expected %q but got %q for CodeName", v.Expected.CodeName, actual.CodeName) + } + + } +} + +func TestParseCodeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CodeId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/codes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOdEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/codes/codeName", + Expected: &CodeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + CodeName: "codeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/codes/codeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOdEs/cOdEnAmE", + Expected: &CodeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + CodeName: "cOdEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOdEs/cOdEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCodeIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.CodeName != v.Expected.CodeName { + t.Fatalf("Expected %q but got %q for CodeName", v.Expected.CodeName, actual.CodeName) + } + + } +} + +func TestSegmentsForCodeId(t *testing.T) { + segments := CodeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CodeId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codecontainer/id_registry.go b/resource-manager/machinelearningservices/2025-04-01/codecontainer/id_registry.go new file mode 100644 index 00000000000..ca127bb2b7e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codecontainer/id_registry.go @@ -0,0 +1,130 @@ +package codecontainer + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RegistryId{}) +} + +var _ resourceids.ResourceId = &RegistryId{} + +// RegistryId is a struct representing the Resource ID for a Registry +type RegistryId struct { + SubscriptionId string + ResourceGroupName string + RegistryName string +} + +// NewRegistryID returns a new RegistryId struct +func NewRegistryID(subscriptionId string, resourceGroupName string, registryName string) RegistryId { + return RegistryId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RegistryName: registryName, + } +} + +// ParseRegistryID parses 'input' into a RegistryId +func ParseRegistryID(input string) (*RegistryId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRegistryIDInsensitively parses 'input' case-insensitively into a RegistryId +// note: this method should only be used for API response data and not user input +func ParseRegistryIDInsensitively(input string) (*RegistryId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RegistryId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RegistryName, ok = input.Parsed["registryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "registryName", input) + } + + return nil +} + +// ValidateRegistryID checks that 'input' can be parsed as a Registry ID +func ValidateRegistryID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRegistryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Registry ID +func (id RegistryId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/registries/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RegistryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Registry ID +func (id RegistryId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticRegistries", "registries", "registries"), + resourceids.UserSpecifiedSegment("registryName", "registryName"), + } +} + +// String returns a human-readable description of this Registry ID +func (id RegistryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Registry Name: %q", id.RegistryName), + } + return fmt.Sprintf("Registry (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codecontainer/id_registry_test.go b/resource-manager/machinelearningservices/2025-04-01/codecontainer/id_registry_test.go new file mode 100644 index 00000000000..3d2f1a81c1a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codecontainer/id_registry_test.go @@ -0,0 +1,282 @@ +package codecontainer + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RegistryId{} + +func TestNewRegistryID(t *testing.T) { + id := NewRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RegistryName != "registryName" { + t.Fatalf("Expected %q but got %q for Segment 'RegistryName'", id.RegistryName, "registryName") + } +} + +func TestFormatRegistryID(t *testing.T) { + actual := NewRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRegistryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Expected: &RegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + } +} + +func TestParseRegistryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Expected: &RegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE", + Expected: &RegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RegistryName: "rEgIsTrYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + } +} + +func TestSegmentsForRegistryId(t *testing.T) { + segments := RegistryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RegistryId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codecontainer/id_registrycode.go b/resource-manager/machinelearningservices/2025-04-01/codecontainer/id_registrycode.go new file mode 100644 index 00000000000..42989712759 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codecontainer/id_registrycode.go @@ -0,0 +1,139 @@ +package codecontainer + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RegistryCodeId{}) +} + +var _ resourceids.ResourceId = &RegistryCodeId{} + +// RegistryCodeId is a struct representing the Resource ID for a Registry Code +type RegistryCodeId struct { + SubscriptionId string + ResourceGroupName string + RegistryName string + CodeName string +} + +// NewRegistryCodeID returns a new RegistryCodeId struct +func NewRegistryCodeID(subscriptionId string, resourceGroupName string, registryName string, codeName string) RegistryCodeId { + return RegistryCodeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RegistryName: registryName, + CodeName: codeName, + } +} + +// ParseRegistryCodeID parses 'input' into a RegistryCodeId +func ParseRegistryCodeID(input string) (*RegistryCodeId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryCodeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryCodeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRegistryCodeIDInsensitively parses 'input' case-insensitively into a RegistryCodeId +// note: this method should only be used for API response data and not user input +func ParseRegistryCodeIDInsensitively(input string) (*RegistryCodeId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryCodeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryCodeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RegistryCodeId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RegistryName, ok = input.Parsed["registryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "registryName", input) + } + + if id.CodeName, ok = input.Parsed["codeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "codeName", input) + } + + return nil +} + +// ValidateRegistryCodeID checks that 'input' can be parsed as a Registry Code ID +func ValidateRegistryCodeID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRegistryCodeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Registry Code ID +func (id RegistryCodeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/registries/%s/codes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RegistryName, id.CodeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Registry Code ID +func (id RegistryCodeId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticRegistries", "registries", "registries"), + resourceids.UserSpecifiedSegment("registryName", "registryName"), + resourceids.StaticSegment("staticCodes", "codes", "codes"), + resourceids.UserSpecifiedSegment("codeName", "codeName"), + } +} + +// String returns a human-readable description of this Registry Code ID +func (id RegistryCodeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Registry Name: %q", id.RegistryName), + fmt.Sprintf("Code Name: %q", id.CodeName), + } + return fmt.Sprintf("Registry Code (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codecontainer/id_registrycode_test.go b/resource-manager/machinelearningservices/2025-04-01/codecontainer/id_registrycode_test.go new file mode 100644 index 00000000000..cff470d61ba --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codecontainer/id_registrycode_test.go @@ -0,0 +1,327 @@ +package codecontainer + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RegistryCodeId{} + +func TestNewRegistryCodeID(t *testing.T) { + id := NewRegistryCodeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "codeName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RegistryName != "registryName" { + t.Fatalf("Expected %q but got %q for Segment 'RegistryName'", id.RegistryName, "registryName") + } + + if id.CodeName != "codeName" { + t.Fatalf("Expected %q but got %q for Segment 'CodeName'", id.CodeName, "codeName") + } +} + +func TestFormatRegistryCodeID(t *testing.T) { + actual := NewRegistryCodeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "codeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/codes/codeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRegistryCodeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryCodeId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/codes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/codes/codeName", + Expected: &RegistryCodeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + CodeName: "codeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/codes/codeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryCodeID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.CodeName != v.Expected.CodeName { + t.Fatalf("Expected %q but got %q for CodeName", v.Expected.CodeName, actual.CodeName) + } + + } +} + +func TestParseRegistryCodeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryCodeId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/codes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/cOdEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/codes/codeName", + Expected: &RegistryCodeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + CodeName: "codeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/codes/codeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/cOdEs/cOdEnAmE", + Expected: &RegistryCodeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RegistryName: "rEgIsTrYnAmE", + CodeName: "cOdEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/cOdEs/cOdEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryCodeIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.CodeName != v.Expected.CodeName { + t.Fatalf("Expected %q but got %q for CodeName", v.Expected.CodeName, actual.CodeName) + } + + } +} + +func TestSegmentsForRegistryCodeId(t *testing.T) { + segments := RegistryCodeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RegistryCodeId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codecontainer/id_workspace.go b/resource-manager/machinelearningservices/2025-04-01/codecontainer/id_workspace.go new file mode 100644 index 00000000000..60d1fcac110 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codecontainer/id_workspace.go @@ -0,0 +1,130 @@ +package codecontainer + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codecontainer/id_workspace_test.go b/resource-manager/machinelearningservices/2025-04-01/codecontainer/id_workspace_test.go new file mode 100644 index 00000000000..b7b5133b9b2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codecontainer/id_workspace_test.go @@ -0,0 +1,282 @@ +package codecontainer + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codecontainer/method_createorupdate.go b/resource-manager/machinelearningservices/2025-04-01/codecontainer/method_createorupdate.go new file mode 100644 index 00000000000..a97b022f8c3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codecontainer/method_createorupdate.go @@ -0,0 +1,58 @@ +package codecontainer + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *CodeContainerResource +} + +// CreateOrUpdate ... +func (c CodeContainerClient) CreateOrUpdate(ctx context.Context, id CodeId, input CodeContainerResource) (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 CodeContainerResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codecontainer/method_delete.go b/resource-manager/machinelearningservices/2025-04-01/codecontainer/method_delete.go new file mode 100644 index 00000000000..cf96ff6f84d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codecontainer/method_delete.go @@ -0,0 +1,47 @@ +package codecontainer + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 CodeContainerClient) Delete(ctx context.Context, id CodeId) (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/machinelearningservices/2025-04-01/codecontainer/method_get.go b/resource-manager/machinelearningservices/2025-04-01/codecontainer/method_get.go new file mode 100644 index 00000000000..cb25a13fbab --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codecontainer/method_get.go @@ -0,0 +1,53 @@ +package codecontainer + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *CodeContainerResource +} + +// Get ... +func (c CodeContainerClient) Get(ctx context.Context, id CodeId) (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 CodeContainerResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codecontainer/method_list.go b/resource-manager/machinelearningservices/2025-04-01/codecontainer/method_list.go new file mode 100644 index 00000000000..b08f44167a0 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codecontainer/method_list.go @@ -0,0 +1,134 @@ +package codecontainer + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]CodeContainerResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []CodeContainerResource +} + +type ListOperationOptions struct { + Skip *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.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + 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 CodeContainerClient) List(ctx context.Context, id WorkspaceId, 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/codes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CodeContainerResource `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 CodeContainerClient) ListComplete(ctx context.Context, id WorkspaceId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, CodeContainerResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CodeContainerClient) ListCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, options ListOperationOptions, predicate CodeContainerResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]CodeContainerResource, 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/machinelearningservices/2025-04-01/codecontainer/method_registrycodecontainerscreateorupdate.go b/resource-manager/machinelearningservices/2025-04-01/codecontainer/method_registrycodecontainerscreateorupdate.go new file mode 100644 index 00000000000..61b073bf3e0 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codecontainer/method_registrycodecontainerscreateorupdate.go @@ -0,0 +1,75 @@ +package codecontainer + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryCodeContainersCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CodeContainerResource +} + +// RegistryCodeContainersCreateOrUpdate ... +func (c CodeContainerClient) RegistryCodeContainersCreateOrUpdate(ctx context.Context, id RegistryCodeId, input CodeContainerResource) (result RegistryCodeContainersCreateOrUpdateOperationResponse, 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 +} + +// RegistryCodeContainersCreateOrUpdateThenPoll performs RegistryCodeContainersCreateOrUpdate then polls until it's completed +func (c CodeContainerClient) RegistryCodeContainersCreateOrUpdateThenPoll(ctx context.Context, id RegistryCodeId, input CodeContainerResource) error { + result, err := c.RegistryCodeContainersCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RegistryCodeContainersCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegistryCodeContainersCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codecontainer/method_registrycodecontainersdelete.go b/resource-manager/machinelearningservices/2025-04-01/codecontainer/method_registrycodecontainersdelete.go new file mode 100644 index 00000000000..429042c3872 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codecontainer/method_registrycodecontainersdelete.go @@ -0,0 +1,71 @@ +package codecontainer + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryCodeContainersDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RegistryCodeContainersDelete ... +func (c CodeContainerClient) RegistryCodeContainersDelete(ctx context.Context, id RegistryCodeId) (result RegistryCodeContainersDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RegistryCodeContainersDeleteThenPoll performs RegistryCodeContainersDelete then polls until it's completed +func (c CodeContainerClient) RegistryCodeContainersDeleteThenPoll(ctx context.Context, id RegistryCodeId) error { + result, err := c.RegistryCodeContainersDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing RegistryCodeContainersDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegistryCodeContainersDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codecontainer/method_registrycodecontainersget.go b/resource-manager/machinelearningservices/2025-04-01/codecontainer/method_registrycodecontainersget.go new file mode 100644 index 00000000000..e5b1cdadb5f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codecontainer/method_registrycodecontainersget.go @@ -0,0 +1,53 @@ +package codecontainer + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryCodeContainersGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CodeContainerResource +} + +// RegistryCodeContainersGet ... +func (c CodeContainerClient) RegistryCodeContainersGet(ctx context.Context, id RegistryCodeId) (result RegistryCodeContainersGetOperationResponse, 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 CodeContainerResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codecontainer/method_registrycodecontainerslist.go b/resource-manager/machinelearningservices/2025-04-01/codecontainer/method_registrycodecontainerslist.go new file mode 100644 index 00000000000..9e0bbbd899f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codecontainer/method_registrycodecontainerslist.go @@ -0,0 +1,134 @@ +package codecontainer + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryCodeContainersListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CodeContainerResource +} + +type RegistryCodeContainersListCompleteResult struct { + LatestHttpResponse *http.Response + Items []CodeContainerResource +} + +type RegistryCodeContainersListOperationOptions struct { + Skip *string +} + +func DefaultRegistryCodeContainersListOperationOptions() RegistryCodeContainersListOperationOptions { + return RegistryCodeContainersListOperationOptions{} +} + +func (o RegistryCodeContainersListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RegistryCodeContainersListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RegistryCodeContainersListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + return &out +} + +type RegistryCodeContainersListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *RegistryCodeContainersListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// RegistryCodeContainersList ... +func (c CodeContainerClient) RegistryCodeContainersList(ctx context.Context, id RegistryId, options RegistryCodeContainersListOperationOptions) (result RegistryCodeContainersListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &RegistryCodeContainersListCustomPager{}, + Path: fmt.Sprintf("%s/codes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CodeContainerResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RegistryCodeContainersListComplete retrieves all the results into a single object +func (c CodeContainerClient) RegistryCodeContainersListComplete(ctx context.Context, id RegistryId, options RegistryCodeContainersListOperationOptions) (RegistryCodeContainersListCompleteResult, error) { + return c.RegistryCodeContainersListCompleteMatchingPredicate(ctx, id, options, CodeContainerResourceOperationPredicate{}) +} + +// RegistryCodeContainersListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CodeContainerClient) RegistryCodeContainersListCompleteMatchingPredicate(ctx context.Context, id RegistryId, options RegistryCodeContainersListOperationOptions, predicate CodeContainerResourceOperationPredicate) (result RegistryCodeContainersListCompleteResult, err error) { + items := make([]CodeContainerResource, 0) + + resp, err := c.RegistryCodeContainersList(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 = RegistryCodeContainersListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codecontainer/model_codecontainer.go b/resource-manager/machinelearningservices/2025-04-01/codecontainer/model_codecontainer.go new file mode 100644 index 00000000000..0354d6e1877 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codecontainer/model_codecontainer.go @@ -0,0 +1,14 @@ +package codecontainer + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CodeContainer struct { + Description *string `json:"description,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + LatestVersion *string `json:"latestVersion,omitempty"` + NextVersion *string `json:"nextVersion,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ProvisioningState *AssetProvisioningState `json:"provisioningState,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codecontainer/model_codecontainerresource.go b/resource-manager/machinelearningservices/2025-04-01/codecontainer/model_codecontainerresource.go new file mode 100644 index 00000000000..2cae139a145 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codecontainer/model_codecontainerresource.go @@ -0,0 +1,16 @@ +package codecontainer + +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 CodeContainerResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties CodeContainer `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codecontainer/predicates.go b/resource-manager/machinelearningservices/2025-04-01/codecontainer/predicates.go new file mode 100644 index 00000000000..1683062d93a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codecontainer/predicates.go @@ -0,0 +1,27 @@ +package codecontainer + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CodeContainerResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p CodeContainerResourceOperationPredicate) Matches(input CodeContainerResource) 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/machinelearningservices/2025-04-01/codecontainer/version.go b/resource-manager/machinelearningservices/2025-04-01/codecontainer/version.go new file mode 100644 index 00000000000..a601845ff2b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codecontainer/version.go @@ -0,0 +1,10 @@ +package codecontainer + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/codecontainer/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/README.md b/resource-manager/machinelearningservices/2025-04-01/codeversion/README.md new file mode 100644 index 00000000000..d2c61e39626 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/README.md @@ -0,0 +1,211 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/codeversion` Documentation + +The `codeversion` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/codeversion" +``` + + +### Client Initialization + +```go +client := codeversion.NewCodeVersionClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `CodeVersionClient.CreateOrGetStartPendingUpload` + +```go +ctx := context.TODO() +id := codeversion.NewCodeVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "codeName", "versionName") + +payload := codeversion.PendingUploadRequestDto{ + // ... +} + + +read, err := client.CreateOrGetStartPendingUpload(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CodeVersionClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := codeversion.NewCodeVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "codeName", "versionName") + +payload := codeversion.CodeVersionResource{ + // ... +} + + +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: `CodeVersionClient.Delete` + +```go +ctx := context.TODO() +id := codeversion.NewCodeVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "codeName", "versionName") + +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: `CodeVersionClient.Get` + +```go +ctx := context.TODO() +id := codeversion.NewCodeVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "codeName", "versionName") + +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: `CodeVersionClient.List` + +```go +ctx := context.TODO() +id := codeversion.NewCodeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "codeName") + +// alternatively `client.List(ctx, id, codeversion.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, codeversion.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `CodeVersionClient.Publish` + +```go +ctx := context.TODO() +id := codeversion.NewCodeVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "codeName", "versionName") + +payload := codeversion.DestinationAsset{ + // ... +} + + +if err := client.PublishThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CodeVersionClient.RegistryCodeVersionsCreateOrGetStartPendingUpload` + +```go +ctx := context.TODO() +id := codeversion.NewRegistryCodeVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "codeName", "versionName") + +payload := codeversion.PendingUploadRequestDto{ + // ... +} + + +read, err := client.RegistryCodeVersionsCreateOrGetStartPendingUpload(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CodeVersionClient.RegistryCodeVersionsCreateOrUpdate` + +```go +ctx := context.TODO() +id := codeversion.NewRegistryCodeVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "codeName", "versionName") + +payload := codeversion.CodeVersionResource{ + // ... +} + + +if err := client.RegistryCodeVersionsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `CodeVersionClient.RegistryCodeVersionsDelete` + +```go +ctx := context.TODO() +id := codeversion.NewRegistryCodeVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "codeName", "versionName") + +if err := client.RegistryCodeVersionsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `CodeVersionClient.RegistryCodeVersionsGet` + +```go +ctx := context.TODO() +id := codeversion.NewRegistryCodeVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "codeName", "versionName") + +read, err := client.RegistryCodeVersionsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `CodeVersionClient.RegistryCodeVersionsList` + +```go +ctx := context.TODO() +id := codeversion.NewRegistryCodeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "codeName") + +// alternatively `client.RegistryCodeVersionsList(ctx, id, codeversion.DefaultRegistryCodeVersionsListOperationOptions())` can be used to do batched pagination +items, err := client.RegistryCodeVersionsListComplete(ctx, id, codeversion.DefaultRegistryCodeVersionsListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/client.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/client.go new file mode 100644 index 00000000000..58bcd7357a9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/client.go @@ -0,0 +1,26 @@ +package codeversion + +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 CodeVersionClient struct { + Client *resourcemanager.Client +} + +func NewCodeVersionClientWithBaseURI(sdkApi sdkEnv.Api) (*CodeVersionClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "codeversion", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating CodeVersionClient: %+v", err) + } + + return &CodeVersionClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/constants.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/constants.go new file mode 100644 index 00000000000..708a0459b96 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/constants.go @@ -0,0 +1,142 @@ +package codeversion + +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 AssetProvisioningState string + +const ( + AssetProvisioningStateCanceled AssetProvisioningState = "Canceled" + AssetProvisioningStateCreating AssetProvisioningState = "Creating" + AssetProvisioningStateDeleting AssetProvisioningState = "Deleting" + AssetProvisioningStateFailed AssetProvisioningState = "Failed" + AssetProvisioningStateSucceeded AssetProvisioningState = "Succeeded" + AssetProvisioningStateUpdating AssetProvisioningState = "Updating" +) + +func PossibleValuesForAssetProvisioningState() []string { + return []string{ + string(AssetProvisioningStateCanceled), + string(AssetProvisioningStateCreating), + string(AssetProvisioningStateDeleting), + string(AssetProvisioningStateFailed), + string(AssetProvisioningStateSucceeded), + string(AssetProvisioningStateUpdating), + } +} + +func (s *AssetProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAssetProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAssetProvisioningState(input string) (*AssetProvisioningState, error) { + vals := map[string]AssetProvisioningState{ + "canceled": AssetProvisioningStateCanceled, + "creating": AssetProvisioningStateCreating, + "deleting": AssetProvisioningStateDeleting, + "failed": AssetProvisioningStateFailed, + "succeeded": AssetProvisioningStateSucceeded, + "updating": AssetProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AssetProvisioningState(input) + return &out, nil +} + +type PendingUploadCredentialType string + +const ( + PendingUploadCredentialTypeSAS PendingUploadCredentialType = "SAS" +) + +func PossibleValuesForPendingUploadCredentialType() []string { + return []string{ + string(PendingUploadCredentialTypeSAS), + } +} + +func (s *PendingUploadCredentialType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePendingUploadCredentialType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePendingUploadCredentialType(input string) (*PendingUploadCredentialType, error) { + vals := map[string]PendingUploadCredentialType{ + "sas": PendingUploadCredentialTypeSAS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PendingUploadCredentialType(input) + return &out, nil +} + +type PendingUploadType string + +const ( + PendingUploadTypeNone PendingUploadType = "None" + PendingUploadTypeTemporaryBlobReference PendingUploadType = "TemporaryBlobReference" +) + +func PossibleValuesForPendingUploadType() []string { + return []string{ + string(PendingUploadTypeNone), + string(PendingUploadTypeTemporaryBlobReference), + } +} + +func (s *PendingUploadType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePendingUploadType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePendingUploadType(input string) (*PendingUploadType, error) { + vals := map[string]PendingUploadType{ + "none": PendingUploadTypeNone, + "temporaryblobreference": PendingUploadTypeTemporaryBlobReference, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PendingUploadType(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/id_code.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/id_code.go new file mode 100644 index 00000000000..46a99295c50 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/id_code.go @@ -0,0 +1,139 @@ +package codeversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CodeId{}) +} + +var _ resourceids.ResourceId = &CodeId{} + +// CodeId is a struct representing the Resource ID for a Code +type CodeId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + CodeName string +} + +// NewCodeID returns a new CodeId struct +func NewCodeID(subscriptionId string, resourceGroupName string, workspaceName string, codeName string) CodeId { + return CodeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + CodeName: codeName, + } +} + +// ParseCodeID parses 'input' into a CodeId +func ParseCodeID(input string) (*CodeId, error) { + parser := resourceids.NewParserFromResourceIdType(&CodeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CodeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCodeIDInsensitively parses 'input' case-insensitively into a CodeId +// note: this method should only be used for API response data and not user input +func ParseCodeIDInsensitively(input string) (*CodeId, error) { + parser := resourceids.NewParserFromResourceIdType(&CodeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CodeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CodeId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.CodeName, ok = input.Parsed["codeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "codeName", input) + } + + return nil +} + +// ValidateCodeID checks that 'input' can be parsed as a Code ID +func ValidateCodeID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCodeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Code ID +func (id CodeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/codes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.CodeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Code ID +func (id CodeId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticCodes", "codes", "codes"), + resourceids.UserSpecifiedSegment("codeName", "codeName"), + } +} + +// String returns a human-readable description of this Code ID +func (id CodeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Code Name: %q", id.CodeName), + } + return fmt.Sprintf("Code (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/id_code_test.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/id_code_test.go new file mode 100644 index 00000000000..c354037e3b1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/id_code_test.go @@ -0,0 +1,327 @@ +package codeversion + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CodeId{} + +func TestNewCodeID(t *testing.T) { + id := NewCodeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "codeName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.CodeName != "codeName" { + t.Fatalf("Expected %q but got %q for Segment 'CodeName'", id.CodeName, "codeName") + } +} + +func TestFormatCodeID(t *testing.T) { + actual := NewCodeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "codeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/codes/codeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCodeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CodeId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/codes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/codes/codeName", + Expected: &CodeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + CodeName: "codeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/codes/codeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCodeID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.CodeName != v.Expected.CodeName { + t.Fatalf("Expected %q but got %q for CodeName", v.Expected.CodeName, actual.CodeName) + } + + } +} + +func TestParseCodeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CodeId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/codes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOdEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/codes/codeName", + Expected: &CodeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + CodeName: "codeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/codes/codeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOdEs/cOdEnAmE", + Expected: &CodeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + CodeName: "cOdEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOdEs/cOdEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCodeIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.CodeName != v.Expected.CodeName { + t.Fatalf("Expected %q but got %q for CodeName", v.Expected.CodeName, actual.CodeName) + } + + } +} + +func TestSegmentsForCodeId(t *testing.T) { + segments := CodeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CodeId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/id_codeversion.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/id_codeversion.go new file mode 100644 index 00000000000..41c90c25163 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/id_codeversion.go @@ -0,0 +1,148 @@ +package codeversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&CodeVersionId{}) +} + +var _ resourceids.ResourceId = &CodeVersionId{} + +// CodeVersionId is a struct representing the Resource ID for a Code Version +type CodeVersionId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + CodeName string + VersionName string +} + +// NewCodeVersionID returns a new CodeVersionId struct +func NewCodeVersionID(subscriptionId string, resourceGroupName string, workspaceName string, codeName string, versionName string) CodeVersionId { + return CodeVersionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + CodeName: codeName, + VersionName: versionName, + } +} + +// ParseCodeVersionID parses 'input' into a CodeVersionId +func ParseCodeVersionID(input string) (*CodeVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&CodeVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CodeVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseCodeVersionIDInsensitively parses 'input' case-insensitively into a CodeVersionId +// note: this method should only be used for API response data and not user input +func ParseCodeVersionIDInsensitively(input string) (*CodeVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&CodeVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := CodeVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *CodeVersionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.CodeName, ok = input.Parsed["codeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "codeName", input) + } + + if id.VersionName, ok = input.Parsed["versionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "versionName", input) + } + + return nil +} + +// ValidateCodeVersionID checks that 'input' can be parsed as a Code Version ID +func ValidateCodeVersionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseCodeVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Code Version ID +func (id CodeVersionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/codes/%s/versions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.CodeName, id.VersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Code Version ID +func (id CodeVersionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticCodes", "codes", "codes"), + resourceids.UserSpecifiedSegment("codeName", "codeName"), + resourceids.StaticSegment("staticVersions", "versions", "versions"), + resourceids.UserSpecifiedSegment("versionName", "versionName"), + } +} + +// String returns a human-readable description of this Code Version ID +func (id CodeVersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Code Name: %q", id.CodeName), + fmt.Sprintf("Version Name: %q", id.VersionName), + } + return fmt.Sprintf("Code Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/id_codeversion_test.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/id_codeversion_test.go new file mode 100644 index 00000000000..9297b040b54 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/id_codeversion_test.go @@ -0,0 +1,372 @@ +package codeversion + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &CodeVersionId{} + +func TestNewCodeVersionID(t *testing.T) { + id := NewCodeVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "codeName", "versionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.CodeName != "codeName" { + t.Fatalf("Expected %q but got %q for Segment 'CodeName'", id.CodeName, "codeName") + } + + if id.VersionName != "versionName" { + t.Fatalf("Expected %q but got %q for Segment 'VersionName'", id.VersionName, "versionName") + } +} + +func TestFormatCodeVersionID(t *testing.T) { + actual := NewCodeVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "codeName", "versionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/codes/codeName/versions/versionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseCodeVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CodeVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/codes", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/codes/codeName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/codes/codeName/versions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/codes/codeName/versions/versionName", + Expected: &CodeVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + CodeName: "codeName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/codes/codeName/versions/versionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCodeVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.CodeName != v.Expected.CodeName { + t.Fatalf("Expected %q but got %q for CodeName", v.Expected.CodeName, actual.CodeName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestParseCodeVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *CodeVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/codes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOdEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/codes/codeName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOdEs/cOdEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/codes/codeName/versions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOdEs/cOdEnAmE/vErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/codes/codeName/versions/versionName", + Expected: &CodeVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + CodeName: "codeName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/codes/codeName/versions/versionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOdEs/cOdEnAmE/vErSiOnS/vErSiOnNaMe", + Expected: &CodeVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + CodeName: "cOdEnAmE", + VersionName: "vErSiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOdEs/cOdEnAmE/vErSiOnS/vErSiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseCodeVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.CodeName != v.Expected.CodeName { + t.Fatalf("Expected %q but got %q for CodeName", v.Expected.CodeName, actual.CodeName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestSegmentsForCodeVersionId(t *testing.T) { + segments := CodeVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("CodeVersionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/id_registrycode.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/id_registrycode.go new file mode 100644 index 00000000000..f900511d744 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/id_registrycode.go @@ -0,0 +1,139 @@ +package codeversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RegistryCodeId{}) +} + +var _ resourceids.ResourceId = &RegistryCodeId{} + +// RegistryCodeId is a struct representing the Resource ID for a Registry Code +type RegistryCodeId struct { + SubscriptionId string + ResourceGroupName string + RegistryName string + CodeName string +} + +// NewRegistryCodeID returns a new RegistryCodeId struct +func NewRegistryCodeID(subscriptionId string, resourceGroupName string, registryName string, codeName string) RegistryCodeId { + return RegistryCodeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RegistryName: registryName, + CodeName: codeName, + } +} + +// ParseRegistryCodeID parses 'input' into a RegistryCodeId +func ParseRegistryCodeID(input string) (*RegistryCodeId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryCodeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryCodeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRegistryCodeIDInsensitively parses 'input' case-insensitively into a RegistryCodeId +// note: this method should only be used for API response data and not user input +func ParseRegistryCodeIDInsensitively(input string) (*RegistryCodeId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryCodeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryCodeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RegistryCodeId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RegistryName, ok = input.Parsed["registryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "registryName", input) + } + + if id.CodeName, ok = input.Parsed["codeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "codeName", input) + } + + return nil +} + +// ValidateRegistryCodeID checks that 'input' can be parsed as a Registry Code ID +func ValidateRegistryCodeID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRegistryCodeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Registry Code ID +func (id RegistryCodeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/registries/%s/codes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RegistryName, id.CodeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Registry Code ID +func (id RegistryCodeId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticRegistries", "registries", "registries"), + resourceids.UserSpecifiedSegment("registryName", "registryName"), + resourceids.StaticSegment("staticCodes", "codes", "codes"), + resourceids.UserSpecifiedSegment("codeName", "codeName"), + } +} + +// String returns a human-readable description of this Registry Code ID +func (id RegistryCodeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Registry Name: %q", id.RegistryName), + fmt.Sprintf("Code Name: %q", id.CodeName), + } + return fmt.Sprintf("Registry Code (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/id_registrycode_test.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/id_registrycode_test.go new file mode 100644 index 00000000000..e71ee156388 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/id_registrycode_test.go @@ -0,0 +1,327 @@ +package codeversion + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RegistryCodeId{} + +func TestNewRegistryCodeID(t *testing.T) { + id := NewRegistryCodeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "codeName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RegistryName != "registryName" { + t.Fatalf("Expected %q but got %q for Segment 'RegistryName'", id.RegistryName, "registryName") + } + + if id.CodeName != "codeName" { + t.Fatalf("Expected %q but got %q for Segment 'CodeName'", id.CodeName, "codeName") + } +} + +func TestFormatRegistryCodeID(t *testing.T) { + actual := NewRegistryCodeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "codeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/codes/codeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRegistryCodeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryCodeId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/codes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/codes/codeName", + Expected: &RegistryCodeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + CodeName: "codeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/codes/codeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryCodeID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.CodeName != v.Expected.CodeName { + t.Fatalf("Expected %q but got %q for CodeName", v.Expected.CodeName, actual.CodeName) + } + + } +} + +func TestParseRegistryCodeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryCodeId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/codes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/cOdEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/codes/codeName", + Expected: &RegistryCodeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + CodeName: "codeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/codes/codeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/cOdEs/cOdEnAmE", + Expected: &RegistryCodeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RegistryName: "rEgIsTrYnAmE", + CodeName: "cOdEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/cOdEs/cOdEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryCodeIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.CodeName != v.Expected.CodeName { + t.Fatalf("Expected %q but got %q for CodeName", v.Expected.CodeName, actual.CodeName) + } + + } +} + +func TestSegmentsForRegistryCodeId(t *testing.T) { + segments := RegistryCodeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RegistryCodeId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/id_registrycodeversion.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/id_registrycodeversion.go new file mode 100644 index 00000000000..3421e5d9c28 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/id_registrycodeversion.go @@ -0,0 +1,148 @@ +package codeversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RegistryCodeVersionId{}) +} + +var _ resourceids.ResourceId = &RegistryCodeVersionId{} + +// RegistryCodeVersionId is a struct representing the Resource ID for a Registry Code Version +type RegistryCodeVersionId struct { + SubscriptionId string + ResourceGroupName string + RegistryName string + CodeName string + VersionName string +} + +// NewRegistryCodeVersionID returns a new RegistryCodeVersionId struct +func NewRegistryCodeVersionID(subscriptionId string, resourceGroupName string, registryName string, codeName string, versionName string) RegistryCodeVersionId { + return RegistryCodeVersionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RegistryName: registryName, + CodeName: codeName, + VersionName: versionName, + } +} + +// ParseRegistryCodeVersionID parses 'input' into a RegistryCodeVersionId +func ParseRegistryCodeVersionID(input string) (*RegistryCodeVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryCodeVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryCodeVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRegistryCodeVersionIDInsensitively parses 'input' case-insensitively into a RegistryCodeVersionId +// note: this method should only be used for API response data and not user input +func ParseRegistryCodeVersionIDInsensitively(input string) (*RegistryCodeVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryCodeVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryCodeVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RegistryCodeVersionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RegistryName, ok = input.Parsed["registryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "registryName", input) + } + + if id.CodeName, ok = input.Parsed["codeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "codeName", input) + } + + if id.VersionName, ok = input.Parsed["versionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "versionName", input) + } + + return nil +} + +// ValidateRegistryCodeVersionID checks that 'input' can be parsed as a Registry Code Version ID +func ValidateRegistryCodeVersionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRegistryCodeVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Registry Code Version ID +func (id RegistryCodeVersionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/registries/%s/codes/%s/versions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RegistryName, id.CodeName, id.VersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Registry Code Version ID +func (id RegistryCodeVersionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticRegistries", "registries", "registries"), + resourceids.UserSpecifiedSegment("registryName", "registryName"), + resourceids.StaticSegment("staticCodes", "codes", "codes"), + resourceids.UserSpecifiedSegment("codeName", "codeName"), + resourceids.StaticSegment("staticVersions", "versions", "versions"), + resourceids.UserSpecifiedSegment("versionName", "versionName"), + } +} + +// String returns a human-readable description of this Registry Code Version ID +func (id RegistryCodeVersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Registry Name: %q", id.RegistryName), + fmt.Sprintf("Code Name: %q", id.CodeName), + fmt.Sprintf("Version Name: %q", id.VersionName), + } + return fmt.Sprintf("Registry Code Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/id_registrycodeversion_test.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/id_registrycodeversion_test.go new file mode 100644 index 00000000000..57f62f11822 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/id_registrycodeversion_test.go @@ -0,0 +1,372 @@ +package codeversion + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RegistryCodeVersionId{} + +func TestNewRegistryCodeVersionID(t *testing.T) { + id := NewRegistryCodeVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "codeName", "versionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RegistryName != "registryName" { + t.Fatalf("Expected %q but got %q for Segment 'RegistryName'", id.RegistryName, "registryName") + } + + if id.CodeName != "codeName" { + t.Fatalf("Expected %q but got %q for Segment 'CodeName'", id.CodeName, "codeName") + } + + if id.VersionName != "versionName" { + t.Fatalf("Expected %q but got %q for Segment 'VersionName'", id.VersionName, "versionName") + } +} + +func TestFormatRegistryCodeVersionID(t *testing.T) { + actual := NewRegistryCodeVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "codeName", "versionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/codes/codeName/versions/versionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRegistryCodeVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryCodeVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/codes", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/codes/codeName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/codes/codeName/versions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/codes/codeName/versions/versionName", + Expected: &RegistryCodeVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + CodeName: "codeName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/codes/codeName/versions/versionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryCodeVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.CodeName != v.Expected.CodeName { + t.Fatalf("Expected %q but got %q for CodeName", v.Expected.CodeName, actual.CodeName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestParseRegistryCodeVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryCodeVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/codes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/cOdEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/codes/codeName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/cOdEs/cOdEnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/codes/codeName/versions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/cOdEs/cOdEnAmE/vErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/codes/codeName/versions/versionName", + Expected: &RegistryCodeVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + CodeName: "codeName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/codes/codeName/versions/versionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/cOdEs/cOdEnAmE/vErSiOnS/vErSiOnNaMe", + Expected: &RegistryCodeVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RegistryName: "rEgIsTrYnAmE", + CodeName: "cOdEnAmE", + VersionName: "vErSiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/cOdEs/cOdEnAmE/vErSiOnS/vErSiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryCodeVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.CodeName != v.Expected.CodeName { + t.Fatalf("Expected %q but got %q for CodeName", v.Expected.CodeName, actual.CodeName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestSegmentsForRegistryCodeVersionId(t *testing.T) { + segments := RegistryCodeVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RegistryCodeVersionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/method_createorgetstartpendingupload.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/method_createorgetstartpendingupload.go new file mode 100644 index 00000000000..ea31f5b2347 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/method_createorgetstartpendingupload.go @@ -0,0 +1,58 @@ +package codeversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CreateOrGetStartPendingUploadOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PendingUploadResponseDto +} + +// CreateOrGetStartPendingUpload ... +func (c CodeVersionClient) CreateOrGetStartPendingUpload(ctx context.Context, id CodeVersionId, input PendingUploadRequestDto) (result CreateOrGetStartPendingUploadOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/startPendingUpload", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PendingUploadResponseDto + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/method_createorupdate.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/method_createorupdate.go new file mode 100644 index 00000000000..f73034d818b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/method_createorupdate.go @@ -0,0 +1,58 @@ +package codeversion + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *CodeVersionResource +} + +// CreateOrUpdate ... +func (c CodeVersionClient) CreateOrUpdate(ctx context.Context, id CodeVersionId, input CodeVersionResource) (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 CodeVersionResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/method_delete.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/method_delete.go new file mode 100644 index 00000000000..137641088f4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/method_delete.go @@ -0,0 +1,47 @@ +package codeversion + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 CodeVersionClient) Delete(ctx context.Context, id CodeVersionId) (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/machinelearningservices/2025-04-01/codeversion/method_get.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/method_get.go new file mode 100644 index 00000000000..f74a36cf935 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/method_get.go @@ -0,0 +1,53 @@ +package codeversion + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *CodeVersionResource +} + +// Get ... +func (c CodeVersionClient) Get(ctx context.Context, id CodeVersionId) (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 CodeVersionResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/method_list.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/method_list.go new file mode 100644 index 00000000000..19dc59168c3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/method_list.go @@ -0,0 +1,150 @@ +package codeversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]CodeVersionResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []CodeVersionResource +} + +type ListOperationOptions struct { + Hash *string + HashVersion *string + OrderBy *string + Skip *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Hash != nil { + out.Append("hash", fmt.Sprintf("%v", *o.Hash)) + } + if o.HashVersion != nil { + out.Append("hashVersion", fmt.Sprintf("%v", *o.HashVersion)) + } + if o.OrderBy != nil { + out.Append("$orderBy", fmt.Sprintf("%v", *o.OrderBy)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c CodeVersionClient) List(ctx context.Context, id CodeId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/versions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CodeVersionResource `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 CodeVersionClient) ListComplete(ctx context.Context, id CodeId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, CodeVersionResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CodeVersionClient) ListCompleteMatchingPredicate(ctx context.Context, id CodeId, options ListOperationOptions, predicate CodeVersionResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]CodeVersionResource, 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/machinelearningservices/2025-04-01/codeversion/method_publish.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/method_publish.go new file mode 100644 index 00000000000..18422db73c6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/method_publish.go @@ -0,0 +1,74 @@ +package codeversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublishOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Publish ... +func (c CodeVersionClient) Publish(ctx context.Context, id CodeVersionId, input DestinationAsset) (result PublishOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/publish", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// PublishThenPoll performs Publish then polls until it's completed +func (c CodeVersionClient) PublishThenPoll(ctx context.Context, id CodeVersionId, input DestinationAsset) error { + result, err := c.Publish(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Publish: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Publish: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/method_registrycodeversionscreateorgetstartpendingupload.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/method_registrycodeversionscreateorgetstartpendingupload.go new file mode 100644 index 00000000000..19f7d46f353 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/method_registrycodeversionscreateorgetstartpendingupload.go @@ -0,0 +1,58 @@ +package codeversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryCodeVersionsCreateOrGetStartPendingUploadOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PendingUploadResponseDto +} + +// RegistryCodeVersionsCreateOrGetStartPendingUpload ... +func (c CodeVersionClient) RegistryCodeVersionsCreateOrGetStartPendingUpload(ctx context.Context, id RegistryCodeVersionId, input PendingUploadRequestDto) (result RegistryCodeVersionsCreateOrGetStartPendingUploadOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/startPendingUpload", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PendingUploadResponseDto + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/method_registrycodeversionscreateorupdate.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/method_registrycodeversionscreateorupdate.go new file mode 100644 index 00000000000..da44f454a0b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/method_registrycodeversionscreateorupdate.go @@ -0,0 +1,75 @@ +package codeversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryCodeVersionsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *CodeVersionResource +} + +// RegistryCodeVersionsCreateOrUpdate ... +func (c CodeVersionClient) RegistryCodeVersionsCreateOrUpdate(ctx context.Context, id RegistryCodeVersionId, input CodeVersionResource) (result RegistryCodeVersionsCreateOrUpdateOperationResponse, 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 +} + +// RegistryCodeVersionsCreateOrUpdateThenPoll performs RegistryCodeVersionsCreateOrUpdate then polls until it's completed +func (c CodeVersionClient) RegistryCodeVersionsCreateOrUpdateThenPoll(ctx context.Context, id RegistryCodeVersionId, input CodeVersionResource) error { + result, err := c.RegistryCodeVersionsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RegistryCodeVersionsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegistryCodeVersionsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/method_registrycodeversionsdelete.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/method_registrycodeversionsdelete.go new file mode 100644 index 00000000000..081912d4c97 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/method_registrycodeversionsdelete.go @@ -0,0 +1,71 @@ +package codeversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryCodeVersionsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RegistryCodeVersionsDelete ... +func (c CodeVersionClient) RegistryCodeVersionsDelete(ctx context.Context, id RegistryCodeVersionId) (result RegistryCodeVersionsDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RegistryCodeVersionsDeleteThenPoll performs RegistryCodeVersionsDelete then polls until it's completed +func (c CodeVersionClient) RegistryCodeVersionsDeleteThenPoll(ctx context.Context, id RegistryCodeVersionId) error { + result, err := c.RegistryCodeVersionsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing RegistryCodeVersionsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegistryCodeVersionsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/method_registrycodeversionsget.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/method_registrycodeversionsget.go new file mode 100644 index 00000000000..146b07039b1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/method_registrycodeversionsget.go @@ -0,0 +1,53 @@ +package codeversion + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryCodeVersionsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *CodeVersionResource +} + +// RegistryCodeVersionsGet ... +func (c CodeVersionClient) RegistryCodeVersionsGet(ctx context.Context, id RegistryCodeVersionId) (result RegistryCodeVersionsGetOperationResponse, 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 CodeVersionResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/method_registrycodeversionslist.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/method_registrycodeversionslist.go new file mode 100644 index 00000000000..c4f87bc666e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/method_registrycodeversionslist.go @@ -0,0 +1,142 @@ +package codeversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryCodeVersionsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]CodeVersionResource +} + +type RegistryCodeVersionsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []CodeVersionResource +} + +type RegistryCodeVersionsListOperationOptions struct { + OrderBy *string + Skip *string + Top *int64 +} + +func DefaultRegistryCodeVersionsListOperationOptions() RegistryCodeVersionsListOperationOptions { + return RegistryCodeVersionsListOperationOptions{} +} + +func (o RegistryCodeVersionsListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RegistryCodeVersionsListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RegistryCodeVersionsListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.OrderBy != nil { + out.Append("$orderBy", fmt.Sprintf("%v", *o.OrderBy)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type RegistryCodeVersionsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *RegistryCodeVersionsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// RegistryCodeVersionsList ... +func (c CodeVersionClient) RegistryCodeVersionsList(ctx context.Context, id RegistryCodeId, options RegistryCodeVersionsListOperationOptions) (result RegistryCodeVersionsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &RegistryCodeVersionsListCustomPager{}, + Path: fmt.Sprintf("%s/versions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]CodeVersionResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RegistryCodeVersionsListComplete retrieves all the results into a single object +func (c CodeVersionClient) RegistryCodeVersionsListComplete(ctx context.Context, id RegistryCodeId, options RegistryCodeVersionsListOperationOptions) (RegistryCodeVersionsListCompleteResult, error) { + return c.RegistryCodeVersionsListCompleteMatchingPredicate(ctx, id, options, CodeVersionResourceOperationPredicate{}) +} + +// RegistryCodeVersionsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c CodeVersionClient) RegistryCodeVersionsListCompleteMatchingPredicate(ctx context.Context, id RegistryCodeId, options RegistryCodeVersionsListOperationOptions, predicate CodeVersionResourceOperationPredicate) (result RegistryCodeVersionsListCompleteResult, err error) { + items := make([]CodeVersionResource, 0) + + resp, err := c.RegistryCodeVersionsList(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 = RegistryCodeVersionsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/model_blobreferenceforconsumptiondto.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/model_blobreferenceforconsumptiondto.go new file mode 100644 index 00000000000..110dd696d0f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/model_blobreferenceforconsumptiondto.go @@ -0,0 +1,45 @@ +package codeversion + +import ( + "encoding/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 BlobReferenceForConsumptionDto struct { + BlobUri *string `json:"blobUri,omitempty"` + Credential PendingUploadCredentialDto `json:"credential"` + StorageAccountArmId *string `json:"storageAccountArmId,omitempty"` +} + +var _ json.Unmarshaler = &BlobReferenceForConsumptionDto{} + +func (s *BlobReferenceForConsumptionDto) UnmarshalJSON(bytes []byte) error { + var decoded struct { + BlobUri *string `json:"blobUri,omitempty"` + StorageAccountArmId *string `json:"storageAccountArmId,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.BlobUri = decoded.BlobUri + s.StorageAccountArmId = decoded.StorageAccountArmId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling BlobReferenceForConsumptionDto into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["credential"]; ok { + impl, err := UnmarshalPendingUploadCredentialDtoImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Credential' for 'BlobReferenceForConsumptionDto': %+v", err) + } + s.Credential = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/model_codeversion.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/model_codeversion.go new file mode 100644 index 00000000000..6b2f87e5e12 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/model_codeversion.go @@ -0,0 +1,14 @@ +package codeversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CodeVersion struct { + CodeUri *string `json:"codeUri,omitempty"` + Description *string `json:"description,omitempty"` + IsAnonymous *bool `json:"isAnonymous,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ProvisioningState *AssetProvisioningState `json:"provisioningState,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/model_codeversionresource.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/model_codeversionresource.go new file mode 100644 index 00000000000..55fbd9fa762 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/model_codeversionresource.go @@ -0,0 +1,16 @@ +package codeversion + +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 CodeVersionResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties CodeVersion `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/model_destinationasset.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/model_destinationasset.go new file mode 100644 index 00000000000..b1b3ba36756 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/model_destinationasset.go @@ -0,0 +1,10 @@ +package codeversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DestinationAsset struct { + DestinationName *string `json:"destinationName,omitempty"` + DestinationVersion *string `json:"destinationVersion,omitempty"` + RegistryName *string `json:"registryName,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/model_pendinguploadcredentialdto.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/model_pendinguploadcredentialdto.go new file mode 100644 index 00000000000..9f55820f0fe --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/model_pendinguploadcredentialdto.go @@ -0,0 +1,75 @@ +package codeversion + +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 PendingUploadCredentialDto interface { + PendingUploadCredentialDto() BasePendingUploadCredentialDtoImpl +} + +var _ PendingUploadCredentialDto = BasePendingUploadCredentialDtoImpl{} + +type BasePendingUploadCredentialDtoImpl struct { + CredentialType PendingUploadCredentialType `json:"credentialType"` +} + +func (s BasePendingUploadCredentialDtoImpl) PendingUploadCredentialDto() BasePendingUploadCredentialDtoImpl { + return s +} + +var _ PendingUploadCredentialDto = RawPendingUploadCredentialDtoImpl{} + +// RawPendingUploadCredentialDtoImpl 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 RawPendingUploadCredentialDtoImpl struct { + pendingUploadCredentialDto BasePendingUploadCredentialDtoImpl + Type string + Values map[string]interface{} +} + +func (s RawPendingUploadCredentialDtoImpl) PendingUploadCredentialDto() BasePendingUploadCredentialDtoImpl { + return s.pendingUploadCredentialDto +} + +func UnmarshalPendingUploadCredentialDtoImplementation(input []byte) (PendingUploadCredentialDto, 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 PendingUploadCredentialDto into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["credentialType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "SAS") { + var out SASCredentialDto + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SASCredentialDto: %+v", err) + } + return out, nil + } + + var parent BasePendingUploadCredentialDtoImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BasePendingUploadCredentialDtoImpl: %+v", err) + } + + return RawPendingUploadCredentialDtoImpl{ + pendingUploadCredentialDto: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/model_pendinguploadrequestdto.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/model_pendinguploadrequestdto.go new file mode 100644 index 00000000000..819fe9acf0c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/model_pendinguploadrequestdto.go @@ -0,0 +1,9 @@ +package codeversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PendingUploadRequestDto struct { + PendingUploadId *string `json:"pendingUploadId,omitempty"` + PendingUploadType *PendingUploadType `json:"pendingUploadType,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/model_pendinguploadresponsedto.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/model_pendinguploadresponsedto.go new file mode 100644 index 00000000000..673749826de --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/model_pendinguploadresponsedto.go @@ -0,0 +1,10 @@ +package codeversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PendingUploadResponseDto struct { + BlobReferenceForConsumption *BlobReferenceForConsumptionDto `json:"blobReferenceForConsumption,omitempty"` + PendingUploadId *string `json:"pendingUploadId,omitempty"` + PendingUploadType *PendingUploadType `json:"pendingUploadType,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/model_sascredentialdto.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/model_sascredentialdto.go new file mode 100644 index 00000000000..73cb2d470dc --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/model_sascredentialdto.go @@ -0,0 +1,50 @@ +package codeversion + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PendingUploadCredentialDto = SASCredentialDto{} + +type SASCredentialDto struct { + SasUri *string `json:"sasUri,omitempty"` + + // Fields inherited from PendingUploadCredentialDto + + CredentialType PendingUploadCredentialType `json:"credentialType"` +} + +func (s SASCredentialDto) PendingUploadCredentialDto() BasePendingUploadCredentialDtoImpl { + return BasePendingUploadCredentialDtoImpl{ + CredentialType: s.CredentialType, + } +} + +var _ json.Marshaler = SASCredentialDto{} + +func (s SASCredentialDto) MarshalJSON() ([]byte, error) { + type wrapper SASCredentialDto + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SASCredentialDto: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SASCredentialDto: %+v", err) + } + + decoded["credentialType"] = "SAS" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SASCredentialDto: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/codeversion/predicates.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/predicates.go new file mode 100644 index 00000000000..7cdd3f80215 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/predicates.go @@ -0,0 +1,27 @@ +package codeversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CodeVersionResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p CodeVersionResourceOperationPredicate) Matches(input CodeVersionResource) 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/machinelearningservices/2025-04-01/codeversion/version.go b/resource-manager/machinelearningservices/2025-04-01/codeversion/version.go new file mode 100644 index 00000000000..eb543cbf427 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/codeversion/version.go @@ -0,0 +1,10 @@ +package codeversion + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/codeversion/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentcontainer/README.md b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/README.md new file mode 100644 index 00000000000..37c81e4ae6e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/README.md @@ -0,0 +1,152 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/componentcontainer` Documentation + +The `componentcontainer` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/componentcontainer" +``` + + +### Client Initialization + +```go +client := componentcontainer.NewComponentContainerClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ComponentContainerClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := componentcontainer.NewComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "componentName") + +payload := componentcontainer.ComponentContainerResource{ + // ... +} + + +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: `ComponentContainerClient.Delete` + +```go +ctx := context.TODO() +id := componentcontainer.NewComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "componentName") + +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: `ComponentContainerClient.Get` + +```go +ctx := context.TODO() +id := componentcontainer.NewComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "componentName") + +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: `ComponentContainerClient.List` + +```go +ctx := context.TODO() +id := componentcontainer.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +// alternatively `client.List(ctx, id, componentcontainer.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, componentcontainer.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ComponentContainerClient.RegistryComponentContainersCreateOrUpdate` + +```go +ctx := context.TODO() +id := componentcontainer.NewRegistryComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "componentName") + +payload := componentcontainer.ComponentContainerResource{ + // ... +} + + +if err := client.RegistryComponentContainersCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ComponentContainerClient.RegistryComponentContainersDelete` + +```go +ctx := context.TODO() +id := componentcontainer.NewRegistryComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "componentName") + +if err := client.RegistryComponentContainersDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ComponentContainerClient.RegistryComponentContainersGet` + +```go +ctx := context.TODO() +id := componentcontainer.NewRegistryComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "componentName") + +read, err := client.RegistryComponentContainersGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ComponentContainerClient.RegistryComponentContainersList` + +```go +ctx := context.TODO() +id := componentcontainer.NewRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName") + +// alternatively `client.RegistryComponentContainersList(ctx, id, componentcontainer.DefaultRegistryComponentContainersListOperationOptions())` can be used to do batched pagination +items, err := client.RegistryComponentContainersListComplete(ctx, id, componentcontainer.DefaultRegistryComponentContainersListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/componentcontainer/client.go b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/client.go new file mode 100644 index 00000000000..85ab562d851 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/client.go @@ -0,0 +1,26 @@ +package componentcontainer + +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 ComponentContainerClient struct { + Client *resourcemanager.Client +} + +func NewComponentContainerClientWithBaseURI(sdkApi sdkEnv.Api) (*ComponentContainerClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "componentcontainer", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ComponentContainerClient: %+v", err) + } + + return &ComponentContainerClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentcontainer/constants.go b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/constants.go new file mode 100644 index 00000000000..31310eb35ce --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/constants.go @@ -0,0 +1,107 @@ +package componentcontainer + +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 AssetProvisioningState string + +const ( + AssetProvisioningStateCanceled AssetProvisioningState = "Canceled" + AssetProvisioningStateCreating AssetProvisioningState = "Creating" + AssetProvisioningStateDeleting AssetProvisioningState = "Deleting" + AssetProvisioningStateFailed AssetProvisioningState = "Failed" + AssetProvisioningStateSucceeded AssetProvisioningState = "Succeeded" + AssetProvisioningStateUpdating AssetProvisioningState = "Updating" +) + +func PossibleValuesForAssetProvisioningState() []string { + return []string{ + string(AssetProvisioningStateCanceled), + string(AssetProvisioningStateCreating), + string(AssetProvisioningStateDeleting), + string(AssetProvisioningStateFailed), + string(AssetProvisioningStateSucceeded), + string(AssetProvisioningStateUpdating), + } +} + +func (s *AssetProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAssetProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAssetProvisioningState(input string) (*AssetProvisioningState, error) { + vals := map[string]AssetProvisioningState{ + "canceled": AssetProvisioningStateCanceled, + "creating": AssetProvisioningStateCreating, + "deleting": AssetProvisioningStateDeleting, + "failed": AssetProvisioningStateFailed, + "succeeded": AssetProvisioningStateSucceeded, + "updating": AssetProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AssetProvisioningState(input) + return &out, nil +} + +type ListViewType string + +const ( + ListViewTypeActiveOnly ListViewType = "ActiveOnly" + ListViewTypeAll ListViewType = "All" + ListViewTypeArchivedOnly ListViewType = "ArchivedOnly" +) + +func PossibleValuesForListViewType() []string { + return []string{ + string(ListViewTypeActiveOnly), + string(ListViewTypeAll), + string(ListViewTypeArchivedOnly), + } +} + +func (s *ListViewType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseListViewType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseListViewType(input string) (*ListViewType, error) { + vals := map[string]ListViewType{ + "activeonly": ListViewTypeActiveOnly, + "all": ListViewTypeAll, + "archivedonly": ListViewTypeArchivedOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ListViewType(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentcontainer/id_component.go b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/id_component.go new file mode 100644 index 00000000000..1d52cada1f3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/id_component.go @@ -0,0 +1,139 @@ +package componentcontainer + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ComponentId{}) +} + +var _ resourceids.ResourceId = &ComponentId{} + +// ComponentId is a struct representing the Resource ID for a Component +type ComponentId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + ComponentName string +} + +// NewComponentID returns a new ComponentId struct +func NewComponentID(subscriptionId string, resourceGroupName string, workspaceName string, componentName string) ComponentId { + return ComponentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + ComponentName: componentName, + } +} + +// ParseComponentID parses 'input' into a ComponentId +func ParseComponentID(input string) (*ComponentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ComponentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ComponentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseComponentIDInsensitively parses 'input' case-insensitively into a ComponentId +// note: this method should only be used for API response data and not user input +func ParseComponentIDInsensitively(input string) (*ComponentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ComponentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ComponentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ComponentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.ComponentName, ok = input.Parsed["componentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "componentName", input) + } + + return nil +} + +// ValidateComponentID checks that 'input' can be parsed as a Component ID +func ValidateComponentID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseComponentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Component ID +func (id ComponentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/components/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.ComponentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Component ID +func (id ComponentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticComponents", "components", "components"), + resourceids.UserSpecifiedSegment("componentName", "componentName"), + } +} + +// String returns a human-readable description of this Component ID +func (id ComponentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Component Name: %q", id.ComponentName), + } + return fmt.Sprintf("Component (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentcontainer/id_component_test.go b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/id_component_test.go new file mode 100644 index 00000000000..ced62f6bf74 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/id_component_test.go @@ -0,0 +1,327 @@ +package componentcontainer + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ComponentId{} + +func TestNewComponentID(t *testing.T) { + id := NewComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "componentName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.ComponentName != "componentName" { + t.Fatalf("Expected %q but got %q for Segment 'ComponentName'", id.ComponentName, "componentName") + } +} + +func TestFormatComponentID(t *testing.T) { + actual := NewComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "componentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/components/componentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseComponentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ComponentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/components", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/components/componentName", + Expected: &ComponentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + ComponentName: "componentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/components/componentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseComponentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.ComponentName != v.Expected.ComponentName { + t.Fatalf("Expected %q but got %q for ComponentName", v.Expected.ComponentName, actual.ComponentName) + } + + } +} + +func TestParseComponentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ComponentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/components", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOmPoNeNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/components/componentName", + Expected: &ComponentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + ComponentName: "componentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/components/componentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOmPoNeNtS/cOmPoNeNtNaMe", + Expected: &ComponentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + ComponentName: "cOmPoNeNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOmPoNeNtS/cOmPoNeNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseComponentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.ComponentName != v.Expected.ComponentName { + t.Fatalf("Expected %q but got %q for ComponentName", v.Expected.ComponentName, actual.ComponentName) + } + + } +} + +func TestSegmentsForComponentId(t *testing.T) { + segments := ComponentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ComponentId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentcontainer/id_registry.go b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/id_registry.go new file mode 100644 index 00000000000..1b448bee366 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/id_registry.go @@ -0,0 +1,130 @@ +package componentcontainer + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RegistryId{}) +} + +var _ resourceids.ResourceId = &RegistryId{} + +// RegistryId is a struct representing the Resource ID for a Registry +type RegistryId struct { + SubscriptionId string + ResourceGroupName string + RegistryName string +} + +// NewRegistryID returns a new RegistryId struct +func NewRegistryID(subscriptionId string, resourceGroupName string, registryName string) RegistryId { + return RegistryId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RegistryName: registryName, + } +} + +// ParseRegistryID parses 'input' into a RegistryId +func ParseRegistryID(input string) (*RegistryId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRegistryIDInsensitively parses 'input' case-insensitively into a RegistryId +// note: this method should only be used for API response data and not user input +func ParseRegistryIDInsensitively(input string) (*RegistryId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RegistryId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RegistryName, ok = input.Parsed["registryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "registryName", input) + } + + return nil +} + +// ValidateRegistryID checks that 'input' can be parsed as a Registry ID +func ValidateRegistryID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRegistryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Registry ID +func (id RegistryId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/registries/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RegistryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Registry ID +func (id RegistryId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticRegistries", "registries", "registries"), + resourceids.UserSpecifiedSegment("registryName", "registryName"), + } +} + +// String returns a human-readable description of this Registry ID +func (id RegistryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Registry Name: %q", id.RegistryName), + } + return fmt.Sprintf("Registry (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentcontainer/id_registry_test.go b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/id_registry_test.go new file mode 100644 index 00000000000..fd08e39730c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/id_registry_test.go @@ -0,0 +1,282 @@ +package componentcontainer + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RegistryId{} + +func TestNewRegistryID(t *testing.T) { + id := NewRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RegistryName != "registryName" { + t.Fatalf("Expected %q but got %q for Segment 'RegistryName'", id.RegistryName, "registryName") + } +} + +func TestFormatRegistryID(t *testing.T) { + actual := NewRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRegistryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Expected: &RegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + } +} + +func TestParseRegistryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Expected: &RegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE", + Expected: &RegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RegistryName: "rEgIsTrYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + } +} + +func TestSegmentsForRegistryId(t *testing.T) { + segments := RegistryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RegistryId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentcontainer/id_registrycomponent.go b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/id_registrycomponent.go new file mode 100644 index 00000000000..74687037533 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/id_registrycomponent.go @@ -0,0 +1,139 @@ +package componentcontainer + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RegistryComponentId{}) +} + +var _ resourceids.ResourceId = &RegistryComponentId{} + +// RegistryComponentId is a struct representing the Resource ID for a Registry Component +type RegistryComponentId struct { + SubscriptionId string + ResourceGroupName string + RegistryName string + ComponentName string +} + +// NewRegistryComponentID returns a new RegistryComponentId struct +func NewRegistryComponentID(subscriptionId string, resourceGroupName string, registryName string, componentName string) RegistryComponentId { + return RegistryComponentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RegistryName: registryName, + ComponentName: componentName, + } +} + +// ParseRegistryComponentID parses 'input' into a RegistryComponentId +func ParseRegistryComponentID(input string) (*RegistryComponentId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryComponentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryComponentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRegistryComponentIDInsensitively parses 'input' case-insensitively into a RegistryComponentId +// note: this method should only be used for API response data and not user input +func ParseRegistryComponentIDInsensitively(input string) (*RegistryComponentId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryComponentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryComponentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RegistryComponentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RegistryName, ok = input.Parsed["registryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "registryName", input) + } + + if id.ComponentName, ok = input.Parsed["componentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "componentName", input) + } + + return nil +} + +// ValidateRegistryComponentID checks that 'input' can be parsed as a Registry Component ID +func ValidateRegistryComponentID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRegistryComponentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Registry Component ID +func (id RegistryComponentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/registries/%s/components/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RegistryName, id.ComponentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Registry Component ID +func (id RegistryComponentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticRegistries", "registries", "registries"), + resourceids.UserSpecifiedSegment("registryName", "registryName"), + resourceids.StaticSegment("staticComponents", "components", "components"), + resourceids.UserSpecifiedSegment("componentName", "componentName"), + } +} + +// String returns a human-readable description of this Registry Component ID +func (id RegistryComponentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Registry Name: %q", id.RegistryName), + fmt.Sprintf("Component Name: %q", id.ComponentName), + } + return fmt.Sprintf("Registry Component (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentcontainer/id_registrycomponent_test.go b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/id_registrycomponent_test.go new file mode 100644 index 00000000000..356a0b12b80 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/id_registrycomponent_test.go @@ -0,0 +1,327 @@ +package componentcontainer + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RegistryComponentId{} + +func TestNewRegistryComponentID(t *testing.T) { + id := NewRegistryComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "componentName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RegistryName != "registryName" { + t.Fatalf("Expected %q but got %q for Segment 'RegistryName'", id.RegistryName, "registryName") + } + + if id.ComponentName != "componentName" { + t.Fatalf("Expected %q but got %q for Segment 'ComponentName'", id.ComponentName, "componentName") + } +} + +func TestFormatRegistryComponentID(t *testing.T) { + actual := NewRegistryComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "componentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/components/componentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRegistryComponentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryComponentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/components", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/components/componentName", + Expected: &RegistryComponentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + ComponentName: "componentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/components/componentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryComponentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.ComponentName != v.Expected.ComponentName { + t.Fatalf("Expected %q but got %q for ComponentName", v.Expected.ComponentName, actual.ComponentName) + } + + } +} + +func TestParseRegistryComponentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryComponentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/components", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/cOmPoNeNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/components/componentName", + Expected: &RegistryComponentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + ComponentName: "componentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/components/componentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/cOmPoNeNtS/cOmPoNeNtNaMe", + Expected: &RegistryComponentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RegistryName: "rEgIsTrYnAmE", + ComponentName: "cOmPoNeNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/cOmPoNeNtS/cOmPoNeNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryComponentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.ComponentName != v.Expected.ComponentName { + t.Fatalf("Expected %q but got %q for ComponentName", v.Expected.ComponentName, actual.ComponentName) + } + + } +} + +func TestSegmentsForRegistryComponentId(t *testing.T) { + segments := RegistryComponentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RegistryComponentId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentcontainer/id_workspace.go b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/id_workspace.go new file mode 100644 index 00000000000..77f1f348fe2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/id_workspace.go @@ -0,0 +1,130 @@ +package componentcontainer + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentcontainer/id_workspace_test.go b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/id_workspace_test.go new file mode 100644 index 00000000000..4f5fcf2cd22 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/id_workspace_test.go @@ -0,0 +1,282 @@ +package componentcontainer + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentcontainer/method_createorupdate.go b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/method_createorupdate.go new file mode 100644 index 00000000000..6915bf12224 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/method_createorupdate.go @@ -0,0 +1,58 @@ +package componentcontainer + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ComponentContainerResource +} + +// CreateOrUpdate ... +func (c ComponentContainerClient) CreateOrUpdate(ctx context.Context, id ComponentId, input ComponentContainerResource) (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 ComponentContainerResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentcontainer/method_delete.go b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/method_delete.go new file mode 100644 index 00000000000..761f0aeaceb --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/method_delete.go @@ -0,0 +1,47 @@ +package componentcontainer + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 ComponentContainerClient) Delete(ctx context.Context, id ComponentId) (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/machinelearningservices/2025-04-01/componentcontainer/method_get.go b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/method_get.go new file mode 100644 index 00000000000..f056dd9aae9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/method_get.go @@ -0,0 +1,53 @@ +package componentcontainer + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ComponentContainerResource +} + +// Get ... +func (c ComponentContainerClient) Get(ctx context.Context, id ComponentId) (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 ComponentContainerResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentcontainer/method_list.go b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/method_list.go new file mode 100644 index 00000000000..90eee5390bb --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/method_list.go @@ -0,0 +1,138 @@ +package componentcontainer + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]ComponentContainerResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ComponentContainerResource +} + +type ListOperationOptions struct { + ListViewType *ListViewType + Skip *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.ListViewType != nil { + out.Append("listViewType", fmt.Sprintf("%v", *o.ListViewType)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + 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 ComponentContainerClient) List(ctx context.Context, id WorkspaceId, 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/components", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ComponentContainerResource `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 ComponentContainerClient) ListComplete(ctx context.Context, id WorkspaceId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ComponentContainerResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ComponentContainerClient) ListCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, options ListOperationOptions, predicate ComponentContainerResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ComponentContainerResource, 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/machinelearningservices/2025-04-01/componentcontainer/method_registrycomponentcontainerscreateorupdate.go b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/method_registrycomponentcontainerscreateorupdate.go new file mode 100644 index 00000000000..42c3d4eabb3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/method_registrycomponentcontainerscreateorupdate.go @@ -0,0 +1,75 @@ +package componentcontainer + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryComponentContainersCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ComponentContainerResource +} + +// RegistryComponentContainersCreateOrUpdate ... +func (c ComponentContainerClient) RegistryComponentContainersCreateOrUpdate(ctx context.Context, id RegistryComponentId, input ComponentContainerResource) (result RegistryComponentContainersCreateOrUpdateOperationResponse, 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 +} + +// RegistryComponentContainersCreateOrUpdateThenPoll performs RegistryComponentContainersCreateOrUpdate then polls until it's completed +func (c ComponentContainerClient) RegistryComponentContainersCreateOrUpdateThenPoll(ctx context.Context, id RegistryComponentId, input ComponentContainerResource) error { + result, err := c.RegistryComponentContainersCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RegistryComponentContainersCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegistryComponentContainersCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentcontainer/method_registrycomponentcontainersdelete.go b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/method_registrycomponentcontainersdelete.go new file mode 100644 index 00000000000..1adb348ef56 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/method_registrycomponentcontainersdelete.go @@ -0,0 +1,71 @@ +package componentcontainer + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryComponentContainersDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RegistryComponentContainersDelete ... +func (c ComponentContainerClient) RegistryComponentContainersDelete(ctx context.Context, id RegistryComponentId) (result RegistryComponentContainersDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RegistryComponentContainersDeleteThenPoll performs RegistryComponentContainersDelete then polls until it's completed +func (c ComponentContainerClient) RegistryComponentContainersDeleteThenPoll(ctx context.Context, id RegistryComponentId) error { + result, err := c.RegistryComponentContainersDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing RegistryComponentContainersDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegistryComponentContainersDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentcontainer/method_registrycomponentcontainersget.go b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/method_registrycomponentcontainersget.go new file mode 100644 index 00000000000..08eefbe5bbe --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/method_registrycomponentcontainersget.go @@ -0,0 +1,53 @@ +package componentcontainer + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryComponentContainersGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ComponentContainerResource +} + +// RegistryComponentContainersGet ... +func (c ComponentContainerClient) RegistryComponentContainersGet(ctx context.Context, id RegistryComponentId) (result RegistryComponentContainersGetOperationResponse, 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 ComponentContainerResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentcontainer/method_registrycomponentcontainerslist.go b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/method_registrycomponentcontainerslist.go new file mode 100644 index 00000000000..9b772c995eb --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/method_registrycomponentcontainerslist.go @@ -0,0 +1,134 @@ +package componentcontainer + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryComponentContainersListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ComponentContainerResource +} + +type RegistryComponentContainersListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ComponentContainerResource +} + +type RegistryComponentContainersListOperationOptions struct { + Skip *string +} + +func DefaultRegistryComponentContainersListOperationOptions() RegistryComponentContainersListOperationOptions { + return RegistryComponentContainersListOperationOptions{} +} + +func (o RegistryComponentContainersListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RegistryComponentContainersListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RegistryComponentContainersListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + return &out +} + +type RegistryComponentContainersListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *RegistryComponentContainersListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// RegistryComponentContainersList ... +func (c ComponentContainerClient) RegistryComponentContainersList(ctx context.Context, id RegistryId, options RegistryComponentContainersListOperationOptions) (result RegistryComponentContainersListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &RegistryComponentContainersListCustomPager{}, + Path: fmt.Sprintf("%s/components", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ComponentContainerResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RegistryComponentContainersListComplete retrieves all the results into a single object +func (c ComponentContainerClient) RegistryComponentContainersListComplete(ctx context.Context, id RegistryId, options RegistryComponentContainersListOperationOptions) (RegistryComponentContainersListCompleteResult, error) { + return c.RegistryComponentContainersListCompleteMatchingPredicate(ctx, id, options, ComponentContainerResourceOperationPredicate{}) +} + +// RegistryComponentContainersListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ComponentContainerClient) RegistryComponentContainersListCompleteMatchingPredicate(ctx context.Context, id RegistryId, options RegistryComponentContainersListOperationOptions, predicate ComponentContainerResourceOperationPredicate) (result RegistryComponentContainersListCompleteResult, err error) { + items := make([]ComponentContainerResource, 0) + + resp, err := c.RegistryComponentContainersList(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 = RegistryComponentContainersListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentcontainer/model_componentcontainer.go b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/model_componentcontainer.go new file mode 100644 index 00000000000..1aa2f1c6343 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/model_componentcontainer.go @@ -0,0 +1,14 @@ +package componentcontainer + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComponentContainer struct { + Description *string `json:"description,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + LatestVersion *string `json:"latestVersion,omitempty"` + NextVersion *string `json:"nextVersion,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ProvisioningState *AssetProvisioningState `json:"provisioningState,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentcontainer/model_componentcontainerresource.go b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/model_componentcontainerresource.go new file mode 100644 index 00000000000..8a1be79411e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/model_componentcontainerresource.go @@ -0,0 +1,16 @@ +package componentcontainer + +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 ComponentContainerResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties ComponentContainer `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentcontainer/predicates.go b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/predicates.go new file mode 100644 index 00000000000..a7b53e32628 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/predicates.go @@ -0,0 +1,27 @@ +package componentcontainer + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComponentContainerResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ComponentContainerResourceOperationPredicate) Matches(input ComponentContainerResource) 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/machinelearningservices/2025-04-01/componentcontainer/version.go b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/version.go new file mode 100644 index 00000000000..9271630b4e3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentcontainer/version.go @@ -0,0 +1,10 @@ +package componentcontainer + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/componentcontainer/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentversion/README.md b/resource-manager/machinelearningservices/2025-04-01/componentversion/README.md new file mode 100644 index 00000000000..15ec561ed63 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentversion/README.md @@ -0,0 +1,169 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/componentversion` Documentation + +The `componentversion` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/componentversion" +``` + + +### Client Initialization + +```go +client := componentversion.NewComponentVersionClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ComponentVersionClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := componentversion.NewComponentVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "componentName", "versionName") + +payload := componentversion.ComponentVersionResource{ + // ... +} + + +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: `ComponentVersionClient.Delete` + +```go +ctx := context.TODO() +id := componentversion.NewComponentVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "componentName", "versionName") + +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: `ComponentVersionClient.Get` + +```go +ctx := context.TODO() +id := componentversion.NewComponentVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "componentName", "versionName") + +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: `ComponentVersionClient.List` + +```go +ctx := context.TODO() +id := componentversion.NewComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "componentName") + +// alternatively `client.List(ctx, id, componentversion.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, componentversion.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ComponentVersionClient.Publish` + +```go +ctx := context.TODO() +id := componentversion.NewComponentVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "componentName", "versionName") + +payload := componentversion.DestinationAsset{ + // ... +} + + +if err := client.PublishThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ComponentVersionClient.RegistryComponentVersionsCreateOrUpdate` + +```go +ctx := context.TODO() +id := componentversion.NewRegistryComponentVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "componentName", "versionName") + +payload := componentversion.ComponentVersionResource{ + // ... +} + + +if err := client.RegistryComponentVersionsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ComponentVersionClient.RegistryComponentVersionsDelete` + +```go +ctx := context.TODO() +id := componentversion.NewRegistryComponentVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "componentName", "versionName") + +if err := client.RegistryComponentVersionsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ComponentVersionClient.RegistryComponentVersionsGet` + +```go +ctx := context.TODO() +id := componentversion.NewRegistryComponentVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "componentName", "versionName") + +read, err := client.RegistryComponentVersionsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ComponentVersionClient.RegistryComponentVersionsList` + +```go +ctx := context.TODO() +id := componentversion.NewRegistryComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "componentName") + +// alternatively `client.RegistryComponentVersionsList(ctx, id, componentversion.DefaultRegistryComponentVersionsListOperationOptions())` can be used to do batched pagination +items, err := client.RegistryComponentVersionsListComplete(ctx, id, componentversion.DefaultRegistryComponentVersionsListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/componentversion/client.go b/resource-manager/machinelearningservices/2025-04-01/componentversion/client.go new file mode 100644 index 00000000000..d989626c3d5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentversion/client.go @@ -0,0 +1,26 @@ +package componentversion + +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 ComponentVersionClient struct { + Client *resourcemanager.Client +} + +func NewComponentVersionClientWithBaseURI(sdkApi sdkEnv.Api) (*ComponentVersionClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "componentversion", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ComponentVersionClient: %+v", err) + } + + return &ComponentVersionClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentversion/constants.go b/resource-manager/machinelearningservices/2025-04-01/componentversion/constants.go new file mode 100644 index 00000000000..7e1e5344e57 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentversion/constants.go @@ -0,0 +1,107 @@ +package componentversion + +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 AssetProvisioningState string + +const ( + AssetProvisioningStateCanceled AssetProvisioningState = "Canceled" + AssetProvisioningStateCreating AssetProvisioningState = "Creating" + AssetProvisioningStateDeleting AssetProvisioningState = "Deleting" + AssetProvisioningStateFailed AssetProvisioningState = "Failed" + AssetProvisioningStateSucceeded AssetProvisioningState = "Succeeded" + AssetProvisioningStateUpdating AssetProvisioningState = "Updating" +) + +func PossibleValuesForAssetProvisioningState() []string { + return []string{ + string(AssetProvisioningStateCanceled), + string(AssetProvisioningStateCreating), + string(AssetProvisioningStateDeleting), + string(AssetProvisioningStateFailed), + string(AssetProvisioningStateSucceeded), + string(AssetProvisioningStateUpdating), + } +} + +func (s *AssetProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAssetProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAssetProvisioningState(input string) (*AssetProvisioningState, error) { + vals := map[string]AssetProvisioningState{ + "canceled": AssetProvisioningStateCanceled, + "creating": AssetProvisioningStateCreating, + "deleting": AssetProvisioningStateDeleting, + "failed": AssetProvisioningStateFailed, + "succeeded": AssetProvisioningStateSucceeded, + "updating": AssetProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AssetProvisioningState(input) + return &out, nil +} + +type ListViewType string + +const ( + ListViewTypeActiveOnly ListViewType = "ActiveOnly" + ListViewTypeAll ListViewType = "All" + ListViewTypeArchivedOnly ListViewType = "ArchivedOnly" +) + +func PossibleValuesForListViewType() []string { + return []string{ + string(ListViewTypeActiveOnly), + string(ListViewTypeAll), + string(ListViewTypeArchivedOnly), + } +} + +func (s *ListViewType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseListViewType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseListViewType(input string) (*ListViewType, error) { + vals := map[string]ListViewType{ + "activeonly": ListViewTypeActiveOnly, + "all": ListViewTypeAll, + "archivedonly": ListViewTypeArchivedOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ListViewType(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentversion/id_component.go b/resource-manager/machinelearningservices/2025-04-01/componentversion/id_component.go new file mode 100644 index 00000000000..1acfc154380 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentversion/id_component.go @@ -0,0 +1,139 @@ +package componentversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ComponentId{}) +} + +var _ resourceids.ResourceId = &ComponentId{} + +// ComponentId is a struct representing the Resource ID for a Component +type ComponentId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + ComponentName string +} + +// NewComponentID returns a new ComponentId struct +func NewComponentID(subscriptionId string, resourceGroupName string, workspaceName string, componentName string) ComponentId { + return ComponentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + ComponentName: componentName, + } +} + +// ParseComponentID parses 'input' into a ComponentId +func ParseComponentID(input string) (*ComponentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ComponentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ComponentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseComponentIDInsensitively parses 'input' case-insensitively into a ComponentId +// note: this method should only be used for API response data and not user input +func ParseComponentIDInsensitively(input string) (*ComponentId, error) { + parser := resourceids.NewParserFromResourceIdType(&ComponentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ComponentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ComponentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.ComponentName, ok = input.Parsed["componentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "componentName", input) + } + + return nil +} + +// ValidateComponentID checks that 'input' can be parsed as a Component ID +func ValidateComponentID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseComponentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Component ID +func (id ComponentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/components/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.ComponentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Component ID +func (id ComponentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticComponents", "components", "components"), + resourceids.UserSpecifiedSegment("componentName", "componentName"), + } +} + +// String returns a human-readable description of this Component ID +func (id ComponentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Component Name: %q", id.ComponentName), + } + return fmt.Sprintf("Component (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentversion/id_component_test.go b/resource-manager/machinelearningservices/2025-04-01/componentversion/id_component_test.go new file mode 100644 index 00000000000..785f551e285 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentversion/id_component_test.go @@ -0,0 +1,327 @@ +package componentversion + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ComponentId{} + +func TestNewComponentID(t *testing.T) { + id := NewComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "componentName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.ComponentName != "componentName" { + t.Fatalf("Expected %q but got %q for Segment 'ComponentName'", id.ComponentName, "componentName") + } +} + +func TestFormatComponentID(t *testing.T) { + actual := NewComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "componentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/components/componentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseComponentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ComponentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/components", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/components/componentName", + Expected: &ComponentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + ComponentName: "componentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/components/componentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseComponentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.ComponentName != v.Expected.ComponentName { + t.Fatalf("Expected %q but got %q for ComponentName", v.Expected.ComponentName, actual.ComponentName) + } + + } +} + +func TestParseComponentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ComponentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/components", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOmPoNeNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/components/componentName", + Expected: &ComponentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + ComponentName: "componentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/components/componentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOmPoNeNtS/cOmPoNeNtNaMe", + Expected: &ComponentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + ComponentName: "cOmPoNeNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOmPoNeNtS/cOmPoNeNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseComponentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.ComponentName != v.Expected.ComponentName { + t.Fatalf("Expected %q but got %q for ComponentName", v.Expected.ComponentName, actual.ComponentName) + } + + } +} + +func TestSegmentsForComponentId(t *testing.T) { + segments := ComponentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ComponentId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentversion/id_componentversion.go b/resource-manager/machinelearningservices/2025-04-01/componentversion/id_componentversion.go new file mode 100644 index 00000000000..fe328b0eb88 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentversion/id_componentversion.go @@ -0,0 +1,148 @@ +package componentversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ComponentVersionId{}) +} + +var _ resourceids.ResourceId = &ComponentVersionId{} + +// ComponentVersionId is a struct representing the Resource ID for a Component Version +type ComponentVersionId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + ComponentName string + VersionName string +} + +// NewComponentVersionID returns a new ComponentVersionId struct +func NewComponentVersionID(subscriptionId string, resourceGroupName string, workspaceName string, componentName string, versionName string) ComponentVersionId { + return ComponentVersionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + ComponentName: componentName, + VersionName: versionName, + } +} + +// ParseComponentVersionID parses 'input' into a ComponentVersionId +func ParseComponentVersionID(input string) (*ComponentVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ComponentVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ComponentVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseComponentVersionIDInsensitively parses 'input' case-insensitively into a ComponentVersionId +// note: this method should only be used for API response data and not user input +func ParseComponentVersionIDInsensitively(input string) (*ComponentVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ComponentVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ComponentVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ComponentVersionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.ComponentName, ok = input.Parsed["componentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "componentName", input) + } + + if id.VersionName, ok = input.Parsed["versionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "versionName", input) + } + + return nil +} + +// ValidateComponentVersionID checks that 'input' can be parsed as a Component Version ID +func ValidateComponentVersionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseComponentVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Component Version ID +func (id ComponentVersionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/components/%s/versions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.ComponentName, id.VersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Component Version ID +func (id ComponentVersionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticComponents", "components", "components"), + resourceids.UserSpecifiedSegment("componentName", "componentName"), + resourceids.StaticSegment("staticVersions", "versions", "versions"), + resourceids.UserSpecifiedSegment("versionName", "versionName"), + } +} + +// String returns a human-readable description of this Component Version ID +func (id ComponentVersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Component Name: %q", id.ComponentName), + fmt.Sprintf("Version Name: %q", id.VersionName), + } + return fmt.Sprintf("Component Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentversion/id_componentversion_test.go b/resource-manager/machinelearningservices/2025-04-01/componentversion/id_componentversion_test.go new file mode 100644 index 00000000000..7a5e302c908 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentversion/id_componentversion_test.go @@ -0,0 +1,372 @@ +package componentversion + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ComponentVersionId{} + +func TestNewComponentVersionID(t *testing.T) { + id := NewComponentVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "componentName", "versionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.ComponentName != "componentName" { + t.Fatalf("Expected %q but got %q for Segment 'ComponentName'", id.ComponentName, "componentName") + } + + if id.VersionName != "versionName" { + t.Fatalf("Expected %q but got %q for Segment 'VersionName'", id.VersionName, "versionName") + } +} + +func TestFormatComponentVersionID(t *testing.T) { + actual := NewComponentVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "componentName", "versionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/components/componentName/versions/versionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseComponentVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ComponentVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/components", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/components/componentName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/components/componentName/versions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/components/componentName/versions/versionName", + Expected: &ComponentVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + ComponentName: "componentName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/components/componentName/versions/versionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseComponentVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.ComponentName != v.Expected.ComponentName { + t.Fatalf("Expected %q but got %q for ComponentName", v.Expected.ComponentName, actual.ComponentName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestParseComponentVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ComponentVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/components", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOmPoNeNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/components/componentName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOmPoNeNtS/cOmPoNeNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/components/componentName/versions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOmPoNeNtS/cOmPoNeNtNaMe/vErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/components/componentName/versions/versionName", + Expected: &ComponentVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + ComponentName: "componentName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/components/componentName/versions/versionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOmPoNeNtS/cOmPoNeNtNaMe/vErSiOnS/vErSiOnNaMe", + Expected: &ComponentVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + ComponentName: "cOmPoNeNtNaMe", + VersionName: "vErSiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOmPoNeNtS/cOmPoNeNtNaMe/vErSiOnS/vErSiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseComponentVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.ComponentName != v.Expected.ComponentName { + t.Fatalf("Expected %q but got %q for ComponentName", v.Expected.ComponentName, actual.ComponentName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestSegmentsForComponentVersionId(t *testing.T) { + segments := ComponentVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ComponentVersionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentversion/id_registrycomponent.go b/resource-manager/machinelearningservices/2025-04-01/componentversion/id_registrycomponent.go new file mode 100644 index 00000000000..dbefecfe3a8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentversion/id_registrycomponent.go @@ -0,0 +1,139 @@ +package componentversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RegistryComponentId{}) +} + +var _ resourceids.ResourceId = &RegistryComponentId{} + +// RegistryComponentId is a struct representing the Resource ID for a Registry Component +type RegistryComponentId struct { + SubscriptionId string + ResourceGroupName string + RegistryName string + ComponentName string +} + +// NewRegistryComponentID returns a new RegistryComponentId struct +func NewRegistryComponentID(subscriptionId string, resourceGroupName string, registryName string, componentName string) RegistryComponentId { + return RegistryComponentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RegistryName: registryName, + ComponentName: componentName, + } +} + +// ParseRegistryComponentID parses 'input' into a RegistryComponentId +func ParseRegistryComponentID(input string) (*RegistryComponentId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryComponentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryComponentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRegistryComponentIDInsensitively parses 'input' case-insensitively into a RegistryComponentId +// note: this method should only be used for API response data and not user input +func ParseRegistryComponentIDInsensitively(input string) (*RegistryComponentId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryComponentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryComponentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RegistryComponentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RegistryName, ok = input.Parsed["registryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "registryName", input) + } + + if id.ComponentName, ok = input.Parsed["componentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "componentName", input) + } + + return nil +} + +// ValidateRegistryComponentID checks that 'input' can be parsed as a Registry Component ID +func ValidateRegistryComponentID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRegistryComponentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Registry Component ID +func (id RegistryComponentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/registries/%s/components/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RegistryName, id.ComponentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Registry Component ID +func (id RegistryComponentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticRegistries", "registries", "registries"), + resourceids.UserSpecifiedSegment("registryName", "registryName"), + resourceids.StaticSegment("staticComponents", "components", "components"), + resourceids.UserSpecifiedSegment("componentName", "componentName"), + } +} + +// String returns a human-readable description of this Registry Component ID +func (id RegistryComponentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Registry Name: %q", id.RegistryName), + fmt.Sprintf("Component Name: %q", id.ComponentName), + } + return fmt.Sprintf("Registry Component (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentversion/id_registrycomponent_test.go b/resource-manager/machinelearningservices/2025-04-01/componentversion/id_registrycomponent_test.go new file mode 100644 index 00000000000..08104270e91 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentversion/id_registrycomponent_test.go @@ -0,0 +1,327 @@ +package componentversion + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RegistryComponentId{} + +func TestNewRegistryComponentID(t *testing.T) { + id := NewRegistryComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "componentName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RegistryName != "registryName" { + t.Fatalf("Expected %q but got %q for Segment 'RegistryName'", id.RegistryName, "registryName") + } + + if id.ComponentName != "componentName" { + t.Fatalf("Expected %q but got %q for Segment 'ComponentName'", id.ComponentName, "componentName") + } +} + +func TestFormatRegistryComponentID(t *testing.T) { + actual := NewRegistryComponentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "componentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/components/componentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRegistryComponentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryComponentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/components", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/components/componentName", + Expected: &RegistryComponentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + ComponentName: "componentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/components/componentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryComponentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.ComponentName != v.Expected.ComponentName { + t.Fatalf("Expected %q but got %q for ComponentName", v.Expected.ComponentName, actual.ComponentName) + } + + } +} + +func TestParseRegistryComponentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryComponentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/components", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/cOmPoNeNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/components/componentName", + Expected: &RegistryComponentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + ComponentName: "componentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/components/componentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/cOmPoNeNtS/cOmPoNeNtNaMe", + Expected: &RegistryComponentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RegistryName: "rEgIsTrYnAmE", + ComponentName: "cOmPoNeNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/cOmPoNeNtS/cOmPoNeNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryComponentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.ComponentName != v.Expected.ComponentName { + t.Fatalf("Expected %q but got %q for ComponentName", v.Expected.ComponentName, actual.ComponentName) + } + + } +} + +func TestSegmentsForRegistryComponentId(t *testing.T) { + segments := RegistryComponentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RegistryComponentId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentversion/id_registrycomponentversion.go b/resource-manager/machinelearningservices/2025-04-01/componentversion/id_registrycomponentversion.go new file mode 100644 index 00000000000..15794ca31bf --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentversion/id_registrycomponentversion.go @@ -0,0 +1,148 @@ +package componentversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RegistryComponentVersionId{}) +} + +var _ resourceids.ResourceId = &RegistryComponentVersionId{} + +// RegistryComponentVersionId is a struct representing the Resource ID for a Registry Component Version +type RegistryComponentVersionId struct { + SubscriptionId string + ResourceGroupName string + RegistryName string + ComponentName string + VersionName string +} + +// NewRegistryComponentVersionID returns a new RegistryComponentVersionId struct +func NewRegistryComponentVersionID(subscriptionId string, resourceGroupName string, registryName string, componentName string, versionName string) RegistryComponentVersionId { + return RegistryComponentVersionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RegistryName: registryName, + ComponentName: componentName, + VersionName: versionName, + } +} + +// ParseRegistryComponentVersionID parses 'input' into a RegistryComponentVersionId +func ParseRegistryComponentVersionID(input string) (*RegistryComponentVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryComponentVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryComponentVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRegistryComponentVersionIDInsensitively parses 'input' case-insensitively into a RegistryComponentVersionId +// note: this method should only be used for API response data and not user input +func ParseRegistryComponentVersionIDInsensitively(input string) (*RegistryComponentVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryComponentVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryComponentVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RegistryComponentVersionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RegistryName, ok = input.Parsed["registryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "registryName", input) + } + + if id.ComponentName, ok = input.Parsed["componentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "componentName", input) + } + + if id.VersionName, ok = input.Parsed["versionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "versionName", input) + } + + return nil +} + +// ValidateRegistryComponentVersionID checks that 'input' can be parsed as a Registry Component Version ID +func ValidateRegistryComponentVersionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRegistryComponentVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Registry Component Version ID +func (id RegistryComponentVersionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/registries/%s/components/%s/versions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RegistryName, id.ComponentName, id.VersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Registry Component Version ID +func (id RegistryComponentVersionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticRegistries", "registries", "registries"), + resourceids.UserSpecifiedSegment("registryName", "registryName"), + resourceids.StaticSegment("staticComponents", "components", "components"), + resourceids.UserSpecifiedSegment("componentName", "componentName"), + resourceids.StaticSegment("staticVersions", "versions", "versions"), + resourceids.UserSpecifiedSegment("versionName", "versionName"), + } +} + +// String returns a human-readable description of this Registry Component Version ID +func (id RegistryComponentVersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Registry Name: %q", id.RegistryName), + fmt.Sprintf("Component Name: %q", id.ComponentName), + fmt.Sprintf("Version Name: %q", id.VersionName), + } + return fmt.Sprintf("Registry Component Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentversion/id_registrycomponentversion_test.go b/resource-manager/machinelearningservices/2025-04-01/componentversion/id_registrycomponentversion_test.go new file mode 100644 index 00000000000..0675fd8a5f1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentversion/id_registrycomponentversion_test.go @@ -0,0 +1,372 @@ +package componentversion + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RegistryComponentVersionId{} + +func TestNewRegistryComponentVersionID(t *testing.T) { + id := NewRegistryComponentVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "componentName", "versionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RegistryName != "registryName" { + t.Fatalf("Expected %q but got %q for Segment 'RegistryName'", id.RegistryName, "registryName") + } + + if id.ComponentName != "componentName" { + t.Fatalf("Expected %q but got %q for Segment 'ComponentName'", id.ComponentName, "componentName") + } + + if id.VersionName != "versionName" { + t.Fatalf("Expected %q but got %q for Segment 'VersionName'", id.VersionName, "versionName") + } +} + +func TestFormatRegistryComponentVersionID(t *testing.T) { + actual := NewRegistryComponentVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "componentName", "versionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/components/componentName/versions/versionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRegistryComponentVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryComponentVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/components", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/components/componentName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/components/componentName/versions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/components/componentName/versions/versionName", + Expected: &RegistryComponentVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + ComponentName: "componentName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/components/componentName/versions/versionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryComponentVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.ComponentName != v.Expected.ComponentName { + t.Fatalf("Expected %q but got %q for ComponentName", v.Expected.ComponentName, actual.ComponentName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestParseRegistryComponentVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryComponentVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/components", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/cOmPoNeNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/components/componentName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/cOmPoNeNtS/cOmPoNeNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/components/componentName/versions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/cOmPoNeNtS/cOmPoNeNtNaMe/vErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/components/componentName/versions/versionName", + Expected: &RegistryComponentVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + ComponentName: "componentName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/components/componentName/versions/versionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/cOmPoNeNtS/cOmPoNeNtNaMe/vErSiOnS/vErSiOnNaMe", + Expected: &RegistryComponentVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RegistryName: "rEgIsTrYnAmE", + ComponentName: "cOmPoNeNtNaMe", + VersionName: "vErSiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/cOmPoNeNtS/cOmPoNeNtNaMe/vErSiOnS/vErSiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryComponentVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.ComponentName != v.Expected.ComponentName { + t.Fatalf("Expected %q but got %q for ComponentName", v.Expected.ComponentName, actual.ComponentName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestSegmentsForRegistryComponentVersionId(t *testing.T) { + segments := RegistryComponentVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RegistryComponentVersionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentversion/method_createorupdate.go b/resource-manager/machinelearningservices/2025-04-01/componentversion/method_createorupdate.go new file mode 100644 index 00000000000..40712c7f514 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentversion/method_createorupdate.go @@ -0,0 +1,58 @@ +package componentversion + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ComponentVersionResource +} + +// CreateOrUpdate ... +func (c ComponentVersionClient) CreateOrUpdate(ctx context.Context, id ComponentVersionId, input ComponentVersionResource) (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 ComponentVersionResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentversion/method_delete.go b/resource-manager/machinelearningservices/2025-04-01/componentversion/method_delete.go new file mode 100644 index 00000000000..c3ff7e68af7 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentversion/method_delete.go @@ -0,0 +1,47 @@ +package componentversion + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 ComponentVersionClient) Delete(ctx context.Context, id ComponentVersionId) (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/machinelearningservices/2025-04-01/componentversion/method_get.go b/resource-manager/machinelearningservices/2025-04-01/componentversion/method_get.go new file mode 100644 index 00000000000..c3f8eecf2c3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentversion/method_get.go @@ -0,0 +1,53 @@ +package componentversion + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ComponentVersionResource +} + +// Get ... +func (c ComponentVersionClient) Get(ctx context.Context, id ComponentVersionId) (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 ComponentVersionResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentversion/method_list.go b/resource-manager/machinelearningservices/2025-04-01/componentversion/method_list.go new file mode 100644 index 00000000000..b1266d0a918 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentversion/method_list.go @@ -0,0 +1,146 @@ +package componentversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]ComponentVersionResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ComponentVersionResource +} + +type ListOperationOptions struct { + ListViewType *ListViewType + OrderBy *string + Skip *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ListViewType != nil { + out.Append("listViewType", fmt.Sprintf("%v", *o.ListViewType)) + } + if o.OrderBy != nil { + out.Append("$orderBy", fmt.Sprintf("%v", *o.OrderBy)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c ComponentVersionClient) List(ctx context.Context, id ComponentId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/versions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ComponentVersionResource `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 ComponentVersionClient) ListComplete(ctx context.Context, id ComponentId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ComponentVersionResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ComponentVersionClient) ListCompleteMatchingPredicate(ctx context.Context, id ComponentId, options ListOperationOptions, predicate ComponentVersionResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ComponentVersionResource, 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/machinelearningservices/2025-04-01/componentversion/method_publish.go b/resource-manager/machinelearningservices/2025-04-01/componentversion/method_publish.go new file mode 100644 index 00000000000..3ce38dfa182 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentversion/method_publish.go @@ -0,0 +1,74 @@ +package componentversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublishOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Publish ... +func (c ComponentVersionClient) Publish(ctx context.Context, id ComponentVersionId, input DestinationAsset) (result PublishOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/publish", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// PublishThenPoll performs Publish then polls until it's completed +func (c ComponentVersionClient) PublishThenPoll(ctx context.Context, id ComponentVersionId, input DestinationAsset) error { + result, err := c.Publish(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Publish: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Publish: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentversion/method_registrycomponentversionscreateorupdate.go b/resource-manager/machinelearningservices/2025-04-01/componentversion/method_registrycomponentversionscreateorupdate.go new file mode 100644 index 00000000000..1126782e80b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentversion/method_registrycomponentversionscreateorupdate.go @@ -0,0 +1,75 @@ +package componentversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryComponentVersionsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ComponentVersionResource +} + +// RegistryComponentVersionsCreateOrUpdate ... +func (c ComponentVersionClient) RegistryComponentVersionsCreateOrUpdate(ctx context.Context, id RegistryComponentVersionId, input ComponentVersionResource) (result RegistryComponentVersionsCreateOrUpdateOperationResponse, 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 +} + +// RegistryComponentVersionsCreateOrUpdateThenPoll performs RegistryComponentVersionsCreateOrUpdate then polls until it's completed +func (c ComponentVersionClient) RegistryComponentVersionsCreateOrUpdateThenPoll(ctx context.Context, id RegistryComponentVersionId, input ComponentVersionResource) error { + result, err := c.RegistryComponentVersionsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RegistryComponentVersionsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegistryComponentVersionsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentversion/method_registrycomponentversionsdelete.go b/resource-manager/machinelearningservices/2025-04-01/componentversion/method_registrycomponentversionsdelete.go new file mode 100644 index 00000000000..8bd109973e2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentversion/method_registrycomponentversionsdelete.go @@ -0,0 +1,71 @@ +package componentversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryComponentVersionsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RegistryComponentVersionsDelete ... +func (c ComponentVersionClient) RegistryComponentVersionsDelete(ctx context.Context, id RegistryComponentVersionId) (result RegistryComponentVersionsDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RegistryComponentVersionsDeleteThenPoll performs RegistryComponentVersionsDelete then polls until it's completed +func (c ComponentVersionClient) RegistryComponentVersionsDeleteThenPoll(ctx context.Context, id RegistryComponentVersionId) error { + result, err := c.RegistryComponentVersionsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing RegistryComponentVersionsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegistryComponentVersionsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentversion/method_registrycomponentversionsget.go b/resource-manager/machinelearningservices/2025-04-01/componentversion/method_registrycomponentversionsget.go new file mode 100644 index 00000000000..e9f102c4401 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentversion/method_registrycomponentversionsget.go @@ -0,0 +1,53 @@ +package componentversion + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryComponentVersionsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ComponentVersionResource +} + +// RegistryComponentVersionsGet ... +func (c ComponentVersionClient) RegistryComponentVersionsGet(ctx context.Context, id RegistryComponentVersionId) (result RegistryComponentVersionsGetOperationResponse, 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 ComponentVersionResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentversion/method_registrycomponentversionslist.go b/resource-manager/machinelearningservices/2025-04-01/componentversion/method_registrycomponentversionslist.go new file mode 100644 index 00000000000..30f0797105c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentversion/method_registrycomponentversionslist.go @@ -0,0 +1,142 @@ +package componentversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryComponentVersionsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ComponentVersionResource +} + +type RegistryComponentVersionsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ComponentVersionResource +} + +type RegistryComponentVersionsListOperationOptions struct { + OrderBy *string + Skip *string + Top *int64 +} + +func DefaultRegistryComponentVersionsListOperationOptions() RegistryComponentVersionsListOperationOptions { + return RegistryComponentVersionsListOperationOptions{} +} + +func (o RegistryComponentVersionsListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RegistryComponentVersionsListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RegistryComponentVersionsListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.OrderBy != nil { + out.Append("$orderBy", fmt.Sprintf("%v", *o.OrderBy)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type RegistryComponentVersionsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *RegistryComponentVersionsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// RegistryComponentVersionsList ... +func (c ComponentVersionClient) RegistryComponentVersionsList(ctx context.Context, id RegistryComponentId, options RegistryComponentVersionsListOperationOptions) (result RegistryComponentVersionsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &RegistryComponentVersionsListCustomPager{}, + Path: fmt.Sprintf("%s/versions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ComponentVersionResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RegistryComponentVersionsListComplete retrieves all the results into a single object +func (c ComponentVersionClient) RegistryComponentVersionsListComplete(ctx context.Context, id RegistryComponentId, options RegistryComponentVersionsListOperationOptions) (RegistryComponentVersionsListCompleteResult, error) { + return c.RegistryComponentVersionsListCompleteMatchingPredicate(ctx, id, options, ComponentVersionResourceOperationPredicate{}) +} + +// RegistryComponentVersionsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ComponentVersionClient) RegistryComponentVersionsListCompleteMatchingPredicate(ctx context.Context, id RegistryComponentId, options RegistryComponentVersionsListOperationOptions, predicate ComponentVersionResourceOperationPredicate) (result RegistryComponentVersionsListCompleteResult, err error) { + items := make([]ComponentVersionResource, 0) + + resp, err := c.RegistryComponentVersionsList(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 = RegistryComponentVersionsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentversion/model_componentversion.go b/resource-manager/machinelearningservices/2025-04-01/componentversion/model_componentversion.go new file mode 100644 index 00000000000..498d024d285 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentversion/model_componentversion.go @@ -0,0 +1,14 @@ +package componentversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComponentVersion struct { + ComponentSpec *interface{} `json:"componentSpec,omitempty"` + Description *string `json:"description,omitempty"` + IsAnonymous *bool `json:"isAnonymous,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ProvisioningState *AssetProvisioningState `json:"provisioningState,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentversion/model_componentversionresource.go b/resource-manager/machinelearningservices/2025-04-01/componentversion/model_componentversionresource.go new file mode 100644 index 00000000000..46abca8f9f8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentversion/model_componentversionresource.go @@ -0,0 +1,16 @@ +package componentversion + +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 ComponentVersionResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties ComponentVersion `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentversion/model_destinationasset.go b/resource-manager/machinelearningservices/2025-04-01/componentversion/model_destinationasset.go new file mode 100644 index 00000000000..a55d21744b4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentversion/model_destinationasset.go @@ -0,0 +1,10 @@ +package componentversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DestinationAsset struct { + DestinationName *string `json:"destinationName,omitempty"` + DestinationVersion *string `json:"destinationVersion,omitempty"` + RegistryName *string `json:"registryName,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/componentversion/predicates.go b/resource-manager/machinelearningservices/2025-04-01/componentversion/predicates.go new file mode 100644 index 00000000000..a894a1d8ac2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentversion/predicates.go @@ -0,0 +1,27 @@ +package componentversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComponentVersionResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ComponentVersionResourceOperationPredicate) Matches(input ComponentVersionResource) 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/machinelearningservices/2025-04-01/componentversion/version.go b/resource-manager/machinelearningservices/2025-04-01/componentversion/version.go new file mode 100644 index 00000000000..f1c13fa56fc --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/componentversion/version.go @@ -0,0 +1,10 @@ +package componentversion + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/componentversion/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datacontainer/README.md b/resource-manager/machinelearningservices/2025-04-01/datacontainer/README.md new file mode 100644 index 00000000000..317a4832e20 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainer/README.md @@ -0,0 +1,90 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/datacontainer` Documentation + +The `datacontainer` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/datacontainer" +``` + + +### Client Initialization + +```go +client := datacontainer.NewDataContainerClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DataContainerClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := datacontainer.NewWorkspaceDataID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataName") + +payload := datacontainer.DataContainerResource{ + // ... +} + + +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: `DataContainerClient.Delete` + +```go +ctx := context.TODO() +id := datacontainer.NewWorkspaceDataID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataName") + +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: `DataContainerClient.Get` + +```go +ctx := context.TODO() +id := datacontainer.NewWorkspaceDataID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataName") + +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: `DataContainerClient.List` + +```go +ctx := context.TODO() +id := datacontainer.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +// alternatively `client.List(ctx, id, datacontainer.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, datacontainer.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/datacontainer/client.go b/resource-manager/machinelearningservices/2025-04-01/datacontainer/client.go new file mode 100644 index 00000000000..978372c4414 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainer/client.go @@ -0,0 +1,26 @@ +package datacontainer + +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 DataContainerClient struct { + Client *resourcemanager.Client +} + +func NewDataContainerClientWithBaseURI(sdkApi sdkEnv.Api) (*DataContainerClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "datacontainer", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DataContainerClient: %+v", err) + } + + return &DataContainerClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datacontainer/constants.go b/resource-manager/machinelearningservices/2025-04-01/datacontainer/constants.go new file mode 100644 index 00000000000..52c6913248d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainer/constants.go @@ -0,0 +1,98 @@ +package datacontainer + +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 DataType string + +const ( + DataTypeMltable DataType = "mltable" + DataTypeUriFile DataType = "uri_file" + DataTypeUriFolder DataType = "uri_folder" +) + +func PossibleValuesForDataType() []string { + return []string{ + string(DataTypeMltable), + string(DataTypeUriFile), + string(DataTypeUriFolder), + } +} + +func (s *DataType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataType(input string) (*DataType, error) { + vals := map[string]DataType{ + "mltable": DataTypeMltable, + "uri_file": DataTypeUriFile, + "uri_folder": DataTypeUriFolder, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataType(input) + return &out, nil +} + +type ListViewType string + +const ( + ListViewTypeActiveOnly ListViewType = "ActiveOnly" + ListViewTypeAll ListViewType = "All" + ListViewTypeArchivedOnly ListViewType = "ArchivedOnly" +) + +func PossibleValuesForListViewType() []string { + return []string{ + string(ListViewTypeActiveOnly), + string(ListViewTypeAll), + string(ListViewTypeArchivedOnly), + } +} + +func (s *ListViewType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseListViewType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseListViewType(input string) (*ListViewType, error) { + vals := map[string]ListViewType{ + "activeonly": ListViewTypeActiveOnly, + "all": ListViewTypeAll, + "archivedonly": ListViewTypeArchivedOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ListViewType(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datacontainer/id_workspace.go b/resource-manager/machinelearningservices/2025-04-01/datacontainer/id_workspace.go new file mode 100644 index 00000000000..9b4ff73d31f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainer/id_workspace.go @@ -0,0 +1,130 @@ +package datacontainer + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datacontainer/id_workspace_test.go b/resource-manager/machinelearningservices/2025-04-01/datacontainer/id_workspace_test.go new file mode 100644 index 00000000000..7df96ef1f74 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainer/id_workspace_test.go @@ -0,0 +1,282 @@ +package datacontainer + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datacontainer/id_workspacedata.go b/resource-manager/machinelearningservices/2025-04-01/datacontainer/id_workspacedata.go new file mode 100644 index 00000000000..ff312e3029b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainer/id_workspacedata.go @@ -0,0 +1,139 @@ +package datacontainer + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceDataId{}) +} + +var _ resourceids.ResourceId = &WorkspaceDataId{} + +// WorkspaceDataId is a struct representing the Resource ID for a Workspace Data +type WorkspaceDataId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + DataName string +} + +// NewWorkspaceDataID returns a new WorkspaceDataId struct +func NewWorkspaceDataID(subscriptionId string, resourceGroupName string, workspaceName string, dataName string) WorkspaceDataId { + return WorkspaceDataId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + DataName: dataName, + } +} + +// ParseWorkspaceDataID parses 'input' into a WorkspaceDataId +func ParseWorkspaceDataID(input string) (*WorkspaceDataId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceDataId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceDataId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceDataIDInsensitively parses 'input' case-insensitively into a WorkspaceDataId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceDataIDInsensitively(input string) (*WorkspaceDataId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceDataId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceDataId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceDataId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.DataName, ok = input.Parsed["dataName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dataName", input) + } + + return nil +} + +// ValidateWorkspaceDataID checks that 'input' can be parsed as a Workspace Data ID +func ValidateWorkspaceDataID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceDataID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace Data ID +func (id WorkspaceDataId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/data/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.DataName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace Data ID +func (id WorkspaceDataId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticData", "data", "data"), + resourceids.UserSpecifiedSegment("dataName", "dataName"), + } +} + +// String returns a human-readable description of this Workspace Data ID +func (id WorkspaceDataId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Data Name: %q", id.DataName), + } + return fmt.Sprintf("Workspace Data (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datacontainer/id_workspacedata_test.go b/resource-manager/machinelearningservices/2025-04-01/datacontainer/id_workspacedata_test.go new file mode 100644 index 00000000000..00aed403507 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainer/id_workspacedata_test.go @@ -0,0 +1,327 @@ +package datacontainer + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceDataId{} + +func TestNewWorkspaceDataID(t *testing.T) { + id := NewWorkspaceDataID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.DataName != "dataName" { + t.Fatalf("Expected %q but got %q for Segment 'DataName'", id.DataName, "dataName") + } +} + +func TestFormatWorkspaceDataID(t *testing.T) { + actual := NewWorkspaceDataID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/data/dataName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceDataID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceDataId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/data", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/data/dataName", + Expected: &WorkspaceDataId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + DataName: "dataName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/data/dataName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceDataID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.DataName != v.Expected.DataName { + t.Fatalf("Expected %q but got %q for DataName", v.Expected.DataName, actual.DataName) + } + + } +} + +func TestParseWorkspaceDataIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceDataId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/data", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/dAtA", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/data/dataName", + Expected: &WorkspaceDataId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + DataName: "dataName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/data/dataName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/dAtA/dAtAnAmE", + Expected: &WorkspaceDataId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + DataName: "dAtAnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/dAtA/dAtAnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceDataIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.DataName != v.Expected.DataName { + t.Fatalf("Expected %q but got %q for DataName", v.Expected.DataName, actual.DataName) + } + + } +} + +func TestSegmentsForWorkspaceDataId(t *testing.T) { + segments := WorkspaceDataId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceDataId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datacontainer/method_createorupdate.go b/resource-manager/machinelearningservices/2025-04-01/datacontainer/method_createorupdate.go new file mode 100644 index 00000000000..8d250399361 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainer/method_createorupdate.go @@ -0,0 +1,58 @@ +package datacontainer + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *DataContainerResource +} + +// CreateOrUpdate ... +func (c DataContainerClient) CreateOrUpdate(ctx context.Context, id WorkspaceDataId, input DataContainerResource) (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 DataContainerResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datacontainer/method_delete.go b/resource-manager/machinelearningservices/2025-04-01/datacontainer/method_delete.go new file mode 100644 index 00000000000..7f6d99210a0 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainer/method_delete.go @@ -0,0 +1,47 @@ +package datacontainer + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 DataContainerClient) Delete(ctx context.Context, id WorkspaceDataId) (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/machinelearningservices/2025-04-01/datacontainer/method_get.go b/resource-manager/machinelearningservices/2025-04-01/datacontainer/method_get.go new file mode 100644 index 00000000000..0d9487bf2bb --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainer/method_get.go @@ -0,0 +1,53 @@ +package datacontainer + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *DataContainerResource +} + +// Get ... +func (c DataContainerClient) Get(ctx context.Context, id WorkspaceDataId) (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 DataContainerResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datacontainer/method_list.go b/resource-manager/machinelearningservices/2025-04-01/datacontainer/method_list.go new file mode 100644 index 00000000000..b809b73aca1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainer/method_list.go @@ -0,0 +1,138 @@ +package datacontainer + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]DataContainerResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []DataContainerResource +} + +type ListOperationOptions struct { + ListViewType *ListViewType + Skip *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.ListViewType != nil { + out.Append("listViewType", fmt.Sprintf("%v", *o.ListViewType)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + 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 DataContainerClient) List(ctx context.Context, id WorkspaceId, 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/data", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DataContainerResource `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 DataContainerClient) ListComplete(ctx context.Context, id WorkspaceId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, DataContainerResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DataContainerClient) ListCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, options ListOperationOptions, predicate DataContainerResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]DataContainerResource, 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/machinelearningservices/2025-04-01/datacontainer/model_datacontainer.go b/resource-manager/machinelearningservices/2025-04-01/datacontainer/model_datacontainer.go new file mode 100644 index 00000000000..00ae4cb5695 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainer/model_datacontainer.go @@ -0,0 +1,14 @@ +package datacontainer + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataContainer struct { + DataType DataType `json:"dataType"` + Description *string `json:"description,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + LatestVersion *string `json:"latestVersion,omitempty"` + NextVersion *string `json:"nextVersion,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datacontainer/model_datacontainerresource.go b/resource-manager/machinelearningservices/2025-04-01/datacontainer/model_datacontainerresource.go new file mode 100644 index 00000000000..5fa29d743fc --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainer/model_datacontainerresource.go @@ -0,0 +1,16 @@ +package datacontainer + +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 DataContainerResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties DataContainer `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datacontainer/predicates.go b/resource-manager/machinelearningservices/2025-04-01/datacontainer/predicates.go new file mode 100644 index 00000000000..2c77432ebc2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainer/predicates.go @@ -0,0 +1,27 @@ +package datacontainer + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataContainerResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p DataContainerResourceOperationPredicate) Matches(input DataContainerResource) 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/machinelearningservices/2025-04-01/datacontainer/version.go b/resource-manager/machinelearningservices/2025-04-01/datacontainer/version.go new file mode 100644 index 00000000000..70bdec414a4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainer/version.go @@ -0,0 +1,10 @@ +package datacontainer + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/datacontainer/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/README.md b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/README.md new file mode 100644 index 00000000000..fe062843988 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry` Documentation + +The `datacontainerregistry` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry" +``` + + +### Client Initialization + +```go +client := datacontainerregistry.NewDataContainerRegistryClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DataContainerRegistryClient.RegistryDataContainersCreateOrUpdate` + +```go +ctx := context.TODO() +id := datacontainerregistry.NewDataID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "dataName") + +payload := datacontainerregistry.DataContainerResource{ + // ... +} + + +if err := client.RegistryDataContainersCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DataContainerRegistryClient.RegistryDataContainersDelete` + +```go +ctx := context.TODO() +id := datacontainerregistry.NewDataID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "dataName") + +if err := client.RegistryDataContainersDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `DataContainerRegistryClient.RegistryDataContainersGet` + +```go +ctx := context.TODO() +id := datacontainerregistry.NewDataID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "dataName") + +read, err := client.RegistryDataContainersGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DataContainerRegistryClient.RegistryDataContainersList` + +```go +ctx := context.TODO() +id := datacontainerregistry.NewRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName") + +// alternatively `client.RegistryDataContainersList(ctx, id, datacontainerregistry.DefaultRegistryDataContainersListOperationOptions())` can be used to do batched pagination +items, err := client.RegistryDataContainersListComplete(ctx, id, datacontainerregistry.DefaultRegistryDataContainersListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/client.go b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/client.go new file mode 100644 index 00000000000..23805424218 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/client.go @@ -0,0 +1,26 @@ +package datacontainerregistry + +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 DataContainerRegistryClient struct { + Client *resourcemanager.Client +} + +func NewDataContainerRegistryClientWithBaseURI(sdkApi sdkEnv.Api) (*DataContainerRegistryClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "datacontainerregistry", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DataContainerRegistryClient: %+v", err) + } + + return &DataContainerRegistryClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/constants.go b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/constants.go new file mode 100644 index 00000000000..3047d7771d1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/constants.go @@ -0,0 +1,98 @@ +package datacontainerregistry + +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 DataType string + +const ( + DataTypeMltable DataType = "mltable" + DataTypeUriFile DataType = "uri_file" + DataTypeUriFolder DataType = "uri_folder" +) + +func PossibleValuesForDataType() []string { + return []string{ + string(DataTypeMltable), + string(DataTypeUriFile), + string(DataTypeUriFolder), + } +} + +func (s *DataType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataType(input string) (*DataType, error) { + vals := map[string]DataType{ + "mltable": DataTypeMltable, + "uri_file": DataTypeUriFile, + "uri_folder": DataTypeUriFolder, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataType(input) + return &out, nil +} + +type ListViewType string + +const ( + ListViewTypeActiveOnly ListViewType = "ActiveOnly" + ListViewTypeAll ListViewType = "All" + ListViewTypeArchivedOnly ListViewType = "ArchivedOnly" +) + +func PossibleValuesForListViewType() []string { + return []string{ + string(ListViewTypeActiveOnly), + string(ListViewTypeAll), + string(ListViewTypeArchivedOnly), + } +} + +func (s *ListViewType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseListViewType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseListViewType(input string) (*ListViewType, error) { + vals := map[string]ListViewType{ + "activeonly": ListViewTypeActiveOnly, + "all": ListViewTypeAll, + "archivedonly": ListViewTypeArchivedOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ListViewType(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/id_data.go b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/id_data.go new file mode 100644 index 00000000000..e13d4b92d60 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/id_data.go @@ -0,0 +1,139 @@ +package datacontainerregistry + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DataId{}) +} + +var _ resourceids.ResourceId = &DataId{} + +// DataId is a struct representing the Resource ID for a Data +type DataId struct { + SubscriptionId string + ResourceGroupName string + RegistryName string + DataName string +} + +// NewDataID returns a new DataId struct +func NewDataID(subscriptionId string, resourceGroupName string, registryName string, dataName string) DataId { + return DataId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RegistryName: registryName, + DataName: dataName, + } +} + +// ParseDataID parses 'input' into a DataId +func ParseDataID(input string) (*DataId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDataIDInsensitively parses 'input' case-insensitively into a DataId +// note: this method should only be used for API response data and not user input +func ParseDataIDInsensitively(input string) (*DataId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DataId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RegistryName, ok = input.Parsed["registryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "registryName", input) + } + + if id.DataName, ok = input.Parsed["dataName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dataName", input) + } + + return nil +} + +// ValidateDataID checks that 'input' can be parsed as a Data ID +func ValidateDataID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseDataID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Data ID +func (id DataId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/registries/%s/data/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RegistryName, id.DataName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Data ID +func (id DataId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticRegistries", "registries", "registries"), + resourceids.UserSpecifiedSegment("registryName", "registryName"), + resourceids.StaticSegment("staticData", "data", "data"), + resourceids.UserSpecifiedSegment("dataName", "dataName"), + } +} + +// String returns a human-readable description of this Data ID +func (id DataId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Registry Name: %q", id.RegistryName), + fmt.Sprintf("Data Name: %q", id.DataName), + } + return fmt.Sprintf("Data (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/id_data_test.go b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/id_data_test.go new file mode 100644 index 00000000000..c53928bc31b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/id_data_test.go @@ -0,0 +1,327 @@ +package datacontainerregistry + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DataId{} + +func TestNewDataID(t *testing.T) { + id := NewDataID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "dataName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RegistryName != "registryName" { + t.Fatalf("Expected %q but got %q for Segment 'RegistryName'", id.RegistryName, "registryName") + } + + if id.DataName != "dataName" { + t.Fatalf("Expected %q but got %q for Segment 'DataName'", id.DataName, "dataName") + } +} + +func TestFormatDataID(t *testing.T) { + actual := NewDataID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "dataName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/data/dataName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDataID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/data", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/data/dataName", + Expected: &DataId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + DataName: "dataName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/data/dataName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.DataName != v.Expected.DataName { + t.Fatalf("Expected %q but got %q for DataName", v.Expected.DataName, actual.DataName) + } + + } +} + +func TestParseDataIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/data", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/dAtA", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/data/dataName", + Expected: &DataId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + DataName: "dataName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/data/dataName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/dAtA/dAtAnAmE", + Expected: &DataId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RegistryName: "rEgIsTrYnAmE", + DataName: "dAtAnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/dAtA/dAtAnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.DataName != v.Expected.DataName { + t.Fatalf("Expected %q but got %q for DataName", v.Expected.DataName, actual.DataName) + } + + } +} + +func TestSegmentsForDataId(t *testing.T) { + segments := DataId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DataId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/id_registry.go b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/id_registry.go new file mode 100644 index 00000000000..808bb71743f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/id_registry.go @@ -0,0 +1,130 @@ +package datacontainerregistry + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RegistryId{}) +} + +var _ resourceids.ResourceId = &RegistryId{} + +// RegistryId is a struct representing the Resource ID for a Registry +type RegistryId struct { + SubscriptionId string + ResourceGroupName string + RegistryName string +} + +// NewRegistryID returns a new RegistryId struct +func NewRegistryID(subscriptionId string, resourceGroupName string, registryName string) RegistryId { + return RegistryId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RegistryName: registryName, + } +} + +// ParseRegistryID parses 'input' into a RegistryId +func ParseRegistryID(input string) (*RegistryId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRegistryIDInsensitively parses 'input' case-insensitively into a RegistryId +// note: this method should only be used for API response data and not user input +func ParseRegistryIDInsensitively(input string) (*RegistryId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RegistryId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RegistryName, ok = input.Parsed["registryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "registryName", input) + } + + return nil +} + +// ValidateRegistryID checks that 'input' can be parsed as a Registry ID +func ValidateRegistryID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRegistryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Registry ID +func (id RegistryId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/registries/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RegistryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Registry ID +func (id RegistryId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticRegistries", "registries", "registries"), + resourceids.UserSpecifiedSegment("registryName", "registryName"), + } +} + +// String returns a human-readable description of this Registry ID +func (id RegistryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Registry Name: %q", id.RegistryName), + } + return fmt.Sprintf("Registry (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/id_registry_test.go b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/id_registry_test.go new file mode 100644 index 00000000000..383d7746d8f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/id_registry_test.go @@ -0,0 +1,282 @@ +package datacontainerregistry + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RegistryId{} + +func TestNewRegistryID(t *testing.T) { + id := NewRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RegistryName != "registryName" { + t.Fatalf("Expected %q but got %q for Segment 'RegistryName'", id.RegistryName, "registryName") + } +} + +func TestFormatRegistryID(t *testing.T) { + actual := NewRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRegistryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Expected: &RegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + } +} + +func TestParseRegistryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Expected: &RegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE", + Expected: &RegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RegistryName: "rEgIsTrYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + } +} + +func TestSegmentsForRegistryId(t *testing.T) { + segments := RegistryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RegistryId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/method_registrydatacontainerscreateorupdate.go b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/method_registrydatacontainerscreateorupdate.go new file mode 100644 index 00000000000..084ecb03f09 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/method_registrydatacontainerscreateorupdate.go @@ -0,0 +1,75 @@ +package datacontainerregistry + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryDataContainersCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DataContainerResource +} + +// RegistryDataContainersCreateOrUpdate ... +func (c DataContainerRegistryClient) RegistryDataContainersCreateOrUpdate(ctx context.Context, id DataId, input DataContainerResource) (result RegistryDataContainersCreateOrUpdateOperationResponse, 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 +} + +// RegistryDataContainersCreateOrUpdateThenPoll performs RegistryDataContainersCreateOrUpdate then polls until it's completed +func (c DataContainerRegistryClient) RegistryDataContainersCreateOrUpdateThenPoll(ctx context.Context, id DataId, input DataContainerResource) error { + result, err := c.RegistryDataContainersCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RegistryDataContainersCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegistryDataContainersCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/method_registrydatacontainersdelete.go b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/method_registrydatacontainersdelete.go new file mode 100644 index 00000000000..39c12c3045a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/method_registrydatacontainersdelete.go @@ -0,0 +1,71 @@ +package datacontainerregistry + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryDataContainersDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RegistryDataContainersDelete ... +func (c DataContainerRegistryClient) RegistryDataContainersDelete(ctx context.Context, id DataId) (result RegistryDataContainersDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RegistryDataContainersDeleteThenPoll performs RegistryDataContainersDelete then polls until it's completed +func (c DataContainerRegistryClient) RegistryDataContainersDeleteThenPoll(ctx context.Context, id DataId) error { + result, err := c.RegistryDataContainersDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing RegistryDataContainersDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegistryDataContainersDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/method_registrydatacontainersget.go b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/method_registrydatacontainersget.go new file mode 100644 index 00000000000..94a16809760 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/method_registrydatacontainersget.go @@ -0,0 +1,53 @@ +package datacontainerregistry + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryDataContainersGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DataContainerResource +} + +// RegistryDataContainersGet ... +func (c DataContainerRegistryClient) RegistryDataContainersGet(ctx context.Context, id DataId) (result RegistryDataContainersGetOperationResponse, 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 DataContainerResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/method_registrydatacontainerslist.go b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/method_registrydatacontainerslist.go new file mode 100644 index 00000000000..11a41c5965e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/method_registrydatacontainerslist.go @@ -0,0 +1,138 @@ +package datacontainerregistry + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryDataContainersListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DataContainerResource +} + +type RegistryDataContainersListCompleteResult struct { + LatestHttpResponse *http.Response + Items []DataContainerResource +} + +type RegistryDataContainersListOperationOptions struct { + ListViewType *ListViewType + Skip *string +} + +func DefaultRegistryDataContainersListOperationOptions() RegistryDataContainersListOperationOptions { + return RegistryDataContainersListOperationOptions{} +} + +func (o RegistryDataContainersListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RegistryDataContainersListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RegistryDataContainersListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ListViewType != nil { + out.Append("listViewType", fmt.Sprintf("%v", *o.ListViewType)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + return &out +} + +type RegistryDataContainersListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *RegistryDataContainersListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// RegistryDataContainersList ... +func (c DataContainerRegistryClient) RegistryDataContainersList(ctx context.Context, id RegistryId, options RegistryDataContainersListOperationOptions) (result RegistryDataContainersListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &RegistryDataContainersListCustomPager{}, + Path: fmt.Sprintf("%s/data", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DataContainerResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RegistryDataContainersListComplete retrieves all the results into a single object +func (c DataContainerRegistryClient) RegistryDataContainersListComplete(ctx context.Context, id RegistryId, options RegistryDataContainersListOperationOptions) (RegistryDataContainersListCompleteResult, error) { + return c.RegistryDataContainersListCompleteMatchingPredicate(ctx, id, options, DataContainerResourceOperationPredicate{}) +} + +// RegistryDataContainersListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DataContainerRegistryClient) RegistryDataContainersListCompleteMatchingPredicate(ctx context.Context, id RegistryId, options RegistryDataContainersListOperationOptions, predicate DataContainerResourceOperationPredicate) (result RegistryDataContainersListCompleteResult, err error) { + items := make([]DataContainerResource, 0) + + resp, err := c.RegistryDataContainersList(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 = RegistryDataContainersListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/model_datacontainer.go b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/model_datacontainer.go new file mode 100644 index 00000000000..5790aac65e9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/model_datacontainer.go @@ -0,0 +1,14 @@ +package datacontainerregistry + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataContainer struct { + DataType DataType `json:"dataType"` + Description *string `json:"description,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + LatestVersion *string `json:"latestVersion,omitempty"` + NextVersion *string `json:"nextVersion,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/model_datacontainerresource.go b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/model_datacontainerresource.go new file mode 100644 index 00000000000..51eabec47c6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/model_datacontainerresource.go @@ -0,0 +1,16 @@ +package datacontainerregistry + +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 DataContainerResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties DataContainer `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/predicates.go b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/predicates.go new file mode 100644 index 00000000000..c03ad5f907e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/predicates.go @@ -0,0 +1,27 @@ +package datacontainerregistry + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataContainerResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p DataContainerResourceOperationPredicate) Matches(input DataContainerResource) 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/machinelearningservices/2025-04-01/datacontainerregistry/version.go b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/version.go new file mode 100644 index 00000000000..4b2f71fef4d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datacontainerregistry/version.go @@ -0,0 +1,10 @@ +package datacontainerregistry + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/datacontainerregistry/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datareference/README.md b/resource-manager/machinelearningservices/2025-04-01/datareference/README.md new file mode 100644 index 00000000000..76fd2312dd3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datareference/README.md @@ -0,0 +1,41 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/datareference` Documentation + +The `datareference` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/datareference" +``` + + +### Client Initialization + +```go +client := datareference.NewDataReferenceClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DataReferenceClient.RegistryDataReferencesGetBlobReferenceSAS` + +```go +ctx := context.TODO() +id := datareference.NewDataReferenceVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "dataReferenceName", "versionName") + +payload := datareference.GetBlobReferenceSASRequestDto{ + // ... +} + + +read, err := client.RegistryDataReferencesGetBlobReferenceSAS(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/machinelearningservices/2025-04-01/datareference/client.go b/resource-manager/machinelearningservices/2025-04-01/datareference/client.go new file mode 100644 index 00000000000..ad8c9e30ef4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datareference/client.go @@ -0,0 +1,26 @@ +package datareference + +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 DataReferenceClient struct { + Client *resourcemanager.Client +} + +func NewDataReferenceClientWithBaseURI(sdkApi sdkEnv.Api) (*DataReferenceClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "datareference", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DataReferenceClient: %+v", err) + } + + return &DataReferenceClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datareference/constants.go b/resource-manager/machinelearningservices/2025-04-01/datareference/constants.go new file mode 100644 index 00000000000..6c61937b0f6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datareference/constants.go @@ -0,0 +1,57 @@ +package datareference + +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 DataReferenceCredentialType string + +const ( + DataReferenceCredentialTypeDockerCredentials DataReferenceCredentialType = "DockerCredentials" + DataReferenceCredentialTypeManagedIdentity DataReferenceCredentialType = "ManagedIdentity" + DataReferenceCredentialTypeNoCredentials DataReferenceCredentialType = "NoCredentials" + DataReferenceCredentialTypeSAS DataReferenceCredentialType = "SAS" +) + +func PossibleValuesForDataReferenceCredentialType() []string { + return []string{ + string(DataReferenceCredentialTypeDockerCredentials), + string(DataReferenceCredentialTypeManagedIdentity), + string(DataReferenceCredentialTypeNoCredentials), + string(DataReferenceCredentialTypeSAS), + } +} + +func (s *DataReferenceCredentialType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataReferenceCredentialType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataReferenceCredentialType(input string) (*DataReferenceCredentialType, error) { + vals := map[string]DataReferenceCredentialType{ + "dockercredentials": DataReferenceCredentialTypeDockerCredentials, + "managedidentity": DataReferenceCredentialTypeManagedIdentity, + "nocredentials": DataReferenceCredentialTypeNoCredentials, + "sas": DataReferenceCredentialTypeSAS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataReferenceCredentialType(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datareference/id_datareferenceversion.go b/resource-manager/machinelearningservices/2025-04-01/datareference/id_datareferenceversion.go new file mode 100644 index 00000000000..9531cf77ad5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datareference/id_datareferenceversion.go @@ -0,0 +1,148 @@ +package datareference + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DataReferenceVersionId{}) +} + +var _ resourceids.ResourceId = &DataReferenceVersionId{} + +// DataReferenceVersionId is a struct representing the Resource ID for a Data Reference Version +type DataReferenceVersionId struct { + SubscriptionId string + ResourceGroupName string + RegistryName string + DataReferenceName string + VersionName string +} + +// NewDataReferenceVersionID returns a new DataReferenceVersionId struct +func NewDataReferenceVersionID(subscriptionId string, resourceGroupName string, registryName string, dataReferenceName string, versionName string) DataReferenceVersionId { + return DataReferenceVersionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RegistryName: registryName, + DataReferenceName: dataReferenceName, + VersionName: versionName, + } +} + +// ParseDataReferenceVersionID parses 'input' into a DataReferenceVersionId +func ParseDataReferenceVersionID(input string) (*DataReferenceVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataReferenceVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataReferenceVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDataReferenceVersionIDInsensitively parses 'input' case-insensitively into a DataReferenceVersionId +// note: this method should only be used for API response data and not user input +func ParseDataReferenceVersionIDInsensitively(input string) (*DataReferenceVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataReferenceVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataReferenceVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DataReferenceVersionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RegistryName, ok = input.Parsed["registryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "registryName", input) + } + + if id.DataReferenceName, ok = input.Parsed["dataReferenceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dataReferenceName", input) + } + + if id.VersionName, ok = input.Parsed["versionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "versionName", input) + } + + return nil +} + +// ValidateDataReferenceVersionID checks that 'input' can be parsed as a Data Reference Version ID +func ValidateDataReferenceVersionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseDataReferenceVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Data Reference Version ID +func (id DataReferenceVersionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/registries/%s/dataReferences/%s/versions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RegistryName, id.DataReferenceName, id.VersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Data Reference Version ID +func (id DataReferenceVersionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticRegistries", "registries", "registries"), + resourceids.UserSpecifiedSegment("registryName", "registryName"), + resourceids.StaticSegment("staticDataReferences", "dataReferences", "dataReferences"), + resourceids.UserSpecifiedSegment("dataReferenceName", "dataReferenceName"), + resourceids.StaticSegment("staticVersions", "versions", "versions"), + resourceids.UserSpecifiedSegment("versionName", "versionName"), + } +} + +// String returns a human-readable description of this Data Reference Version ID +func (id DataReferenceVersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Registry Name: %q", id.RegistryName), + fmt.Sprintf("Data Reference Name: %q", id.DataReferenceName), + fmt.Sprintf("Version Name: %q", id.VersionName), + } + return fmt.Sprintf("Data Reference Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datareference/id_datareferenceversion_test.go b/resource-manager/machinelearningservices/2025-04-01/datareference/id_datareferenceversion_test.go new file mode 100644 index 00000000000..6609c084ebc --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datareference/id_datareferenceversion_test.go @@ -0,0 +1,372 @@ +package datareference + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DataReferenceVersionId{} + +func TestNewDataReferenceVersionID(t *testing.T) { + id := NewDataReferenceVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "dataReferenceName", "versionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RegistryName != "registryName" { + t.Fatalf("Expected %q but got %q for Segment 'RegistryName'", id.RegistryName, "registryName") + } + + if id.DataReferenceName != "dataReferenceName" { + t.Fatalf("Expected %q but got %q for Segment 'DataReferenceName'", id.DataReferenceName, "dataReferenceName") + } + + if id.VersionName != "versionName" { + t.Fatalf("Expected %q but got %q for Segment 'VersionName'", id.VersionName, "versionName") + } +} + +func TestFormatDataReferenceVersionID(t *testing.T) { + actual := NewDataReferenceVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "dataReferenceName", "versionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/dataReferences/dataReferenceName/versions/versionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDataReferenceVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataReferenceVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/dataReferences", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/dataReferences/dataReferenceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/dataReferences/dataReferenceName/versions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/dataReferences/dataReferenceName/versions/versionName", + Expected: &DataReferenceVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + DataReferenceName: "dataReferenceName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/dataReferences/dataReferenceName/versions/versionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataReferenceVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.DataReferenceName != v.Expected.DataReferenceName { + t.Fatalf("Expected %q but got %q for DataReferenceName", v.Expected.DataReferenceName, actual.DataReferenceName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestParseDataReferenceVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataReferenceVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/dataReferences", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/dAtArEfErEnCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/dataReferences/dataReferenceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/dAtArEfErEnCeS/dAtArEfErEnCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/dataReferences/dataReferenceName/versions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/dAtArEfErEnCeS/dAtArEfErEnCeNaMe/vErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/dataReferences/dataReferenceName/versions/versionName", + Expected: &DataReferenceVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + DataReferenceName: "dataReferenceName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/dataReferences/dataReferenceName/versions/versionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/dAtArEfErEnCeS/dAtArEfErEnCeNaMe/vErSiOnS/vErSiOnNaMe", + Expected: &DataReferenceVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RegistryName: "rEgIsTrYnAmE", + DataReferenceName: "dAtArEfErEnCeNaMe", + VersionName: "vErSiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/dAtArEfErEnCeS/dAtArEfErEnCeNaMe/vErSiOnS/vErSiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataReferenceVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.DataReferenceName != v.Expected.DataReferenceName { + t.Fatalf("Expected %q but got %q for DataReferenceName", v.Expected.DataReferenceName, actual.DataReferenceName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestSegmentsForDataReferenceVersionId(t *testing.T) { + segments := DataReferenceVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DataReferenceVersionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datareference/method_registrydatareferencesgetblobreferencesas.go b/resource-manager/machinelearningservices/2025-04-01/datareference/method_registrydatareferencesgetblobreferencesas.go new file mode 100644 index 00000000000..f43b79412a4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datareference/method_registrydatareferencesgetblobreferencesas.go @@ -0,0 +1,57 @@ +package datareference + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryDataReferencesGetBlobReferenceSASOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *GetBlobReferenceSASResponseDto +} + +// RegistryDataReferencesGetBlobReferenceSAS ... +func (c DataReferenceClient) RegistryDataReferencesGetBlobReferenceSAS(ctx context.Context, id DataReferenceVersionId, input GetBlobReferenceSASRequestDto) (result RegistryDataReferencesGetBlobReferenceSASOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model GetBlobReferenceSASResponseDto + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datareference/model_anonymousaccesscredential.go b/resource-manager/machinelearningservices/2025-04-01/datareference/model_anonymousaccesscredential.go new file mode 100644 index 00000000000..84df7d356c4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datareference/model_anonymousaccesscredential.go @@ -0,0 +1,49 @@ +package datareference + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DataReferenceCredential = AnonymousAccessCredential{} + +type AnonymousAccessCredential struct { + + // Fields inherited from DataReferenceCredential + + CredentialType DataReferenceCredentialType `json:"credentialType"` +} + +func (s AnonymousAccessCredential) DataReferenceCredential() BaseDataReferenceCredentialImpl { + return BaseDataReferenceCredentialImpl{ + CredentialType: s.CredentialType, + } +} + +var _ json.Marshaler = AnonymousAccessCredential{} + +func (s AnonymousAccessCredential) MarshalJSON() ([]byte, error) { + type wrapper AnonymousAccessCredential + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AnonymousAccessCredential: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AnonymousAccessCredential: %+v", err) + } + + decoded["credentialType"] = "NoCredentials" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AnonymousAccessCredential: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datareference/model_datareferencecredential.go b/resource-manager/machinelearningservices/2025-04-01/datareference/model_datareferencecredential.go new file mode 100644 index 00000000000..bcd036240d5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datareference/model_datareferencecredential.go @@ -0,0 +1,99 @@ +package datareference + +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 DataReferenceCredential interface { + DataReferenceCredential() BaseDataReferenceCredentialImpl +} + +var _ DataReferenceCredential = BaseDataReferenceCredentialImpl{} + +type BaseDataReferenceCredentialImpl struct { + CredentialType DataReferenceCredentialType `json:"credentialType"` +} + +func (s BaseDataReferenceCredentialImpl) DataReferenceCredential() BaseDataReferenceCredentialImpl { + return s +} + +var _ DataReferenceCredential = RawDataReferenceCredentialImpl{} + +// RawDataReferenceCredentialImpl 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 RawDataReferenceCredentialImpl struct { + dataReferenceCredential BaseDataReferenceCredentialImpl + Type string + Values map[string]interface{} +} + +func (s RawDataReferenceCredentialImpl) DataReferenceCredential() BaseDataReferenceCredentialImpl { + return s.dataReferenceCredential +} + +func UnmarshalDataReferenceCredentialImplementation(input []byte) (DataReferenceCredential, 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 DataReferenceCredential into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["credentialType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "NoCredentials") { + var out AnonymousAccessCredential + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AnonymousAccessCredential: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DockerCredentials") { + var out DockerCredential + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DockerCredential: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ManagedIdentity") { + var out ManagedIdentityCredential + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ManagedIdentityCredential: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SAS") { + var out SASCredential + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SASCredential: %+v", err) + } + return out, nil + } + + var parent BaseDataReferenceCredentialImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseDataReferenceCredentialImpl: %+v", err) + } + + return RawDataReferenceCredentialImpl{ + dataReferenceCredential: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datareference/model_dockercredential.go b/resource-manager/machinelearningservices/2025-04-01/datareference/model_dockercredential.go new file mode 100644 index 00000000000..c479b6dc0f5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datareference/model_dockercredential.go @@ -0,0 +1,51 @@ +package datareference + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DataReferenceCredential = DockerCredential{} + +type DockerCredential struct { + Password *string `json:"password,omitempty"` + UserName *string `json:"userName,omitempty"` + + // Fields inherited from DataReferenceCredential + + CredentialType DataReferenceCredentialType `json:"credentialType"` +} + +func (s DockerCredential) DataReferenceCredential() BaseDataReferenceCredentialImpl { + return BaseDataReferenceCredentialImpl{ + CredentialType: s.CredentialType, + } +} + +var _ json.Marshaler = DockerCredential{} + +func (s DockerCredential) MarshalJSON() ([]byte, error) { + type wrapper DockerCredential + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DockerCredential: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DockerCredential: %+v", err) + } + + decoded["credentialType"] = "DockerCredentials" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DockerCredential: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datareference/model_getblobreferenceforconsumptiondto.go b/resource-manager/machinelearningservices/2025-04-01/datareference/model_getblobreferenceforconsumptiondto.go new file mode 100644 index 00000000000..92fa70cedc3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datareference/model_getblobreferenceforconsumptiondto.go @@ -0,0 +1,45 @@ +package datareference + +import ( + "encoding/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 GetBlobReferenceForConsumptionDto struct { + BlobUri *string `json:"blobUri,omitempty"` + Credential DataReferenceCredential `json:"credential"` + StorageAccountArmId *string `json:"storageAccountArmId,omitempty"` +} + +var _ json.Unmarshaler = &GetBlobReferenceForConsumptionDto{} + +func (s *GetBlobReferenceForConsumptionDto) UnmarshalJSON(bytes []byte) error { + var decoded struct { + BlobUri *string `json:"blobUri,omitempty"` + StorageAccountArmId *string `json:"storageAccountArmId,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.BlobUri = decoded.BlobUri + s.StorageAccountArmId = decoded.StorageAccountArmId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling GetBlobReferenceForConsumptionDto into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["credential"]; ok { + impl, err := UnmarshalDataReferenceCredentialImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Credential' for 'GetBlobReferenceForConsumptionDto': %+v", err) + } + s.Credential = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datareference/model_getblobreferencesasrequestdto.go b/resource-manager/machinelearningservices/2025-04-01/datareference/model_getblobreferencesasrequestdto.go new file mode 100644 index 00000000000..83c7e27de75 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datareference/model_getblobreferencesasrequestdto.go @@ -0,0 +1,9 @@ +package datareference + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetBlobReferenceSASRequestDto struct { + AssetId *string `json:"assetId,omitempty"` + BlobUri *string `json:"blobUri,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datareference/model_getblobreferencesasresponsedto.go b/resource-manager/machinelearningservices/2025-04-01/datareference/model_getblobreferencesasresponsedto.go new file mode 100644 index 00000000000..a72349e0b0f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datareference/model_getblobreferencesasresponsedto.go @@ -0,0 +1,8 @@ +package datareference + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetBlobReferenceSASResponseDto struct { + BlobReferenceForConsumption *GetBlobReferenceForConsumptionDto `json:"blobReferenceForConsumption,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datareference/model_managedidentitycredential.go b/resource-manager/machinelearningservices/2025-04-01/datareference/model_managedidentitycredential.go new file mode 100644 index 00000000000..2ecd6f3ddf8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datareference/model_managedidentitycredential.go @@ -0,0 +1,54 @@ +package datareference + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DataReferenceCredential = ManagedIdentityCredential{} + +type ManagedIdentityCredential struct { + ManagedIdentityType *string `json:"managedIdentityType,omitempty"` + UserManagedIdentityClientId *string `json:"userManagedIdentityClientId,omitempty"` + UserManagedIdentityPrincipalId *string `json:"userManagedIdentityPrincipalId,omitempty"` + UserManagedIdentityResourceId *string `json:"userManagedIdentityResourceId,omitempty"` + UserManagedIdentityTenantId *string `json:"userManagedIdentityTenantId,omitempty"` + + // Fields inherited from DataReferenceCredential + + CredentialType DataReferenceCredentialType `json:"credentialType"` +} + +func (s ManagedIdentityCredential) DataReferenceCredential() BaseDataReferenceCredentialImpl { + return BaseDataReferenceCredentialImpl{ + CredentialType: s.CredentialType, + } +} + +var _ json.Marshaler = ManagedIdentityCredential{} + +func (s ManagedIdentityCredential) MarshalJSON() ([]byte, error) { + type wrapper ManagedIdentityCredential + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ManagedIdentityCredential: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ManagedIdentityCredential: %+v", err) + } + + decoded["credentialType"] = "ManagedIdentity" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ManagedIdentityCredential: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datareference/model_sascredential.go b/resource-manager/machinelearningservices/2025-04-01/datareference/model_sascredential.go new file mode 100644 index 00000000000..ebd4229087b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datareference/model_sascredential.go @@ -0,0 +1,50 @@ +package datareference + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DataReferenceCredential = SASCredential{} + +type SASCredential struct { + SasUri *string `json:"sasUri,omitempty"` + + // Fields inherited from DataReferenceCredential + + CredentialType DataReferenceCredentialType `json:"credentialType"` +} + +func (s SASCredential) DataReferenceCredential() BaseDataReferenceCredentialImpl { + return BaseDataReferenceCredentialImpl{ + CredentialType: s.CredentialType, + } +} + +var _ json.Marshaler = SASCredential{} + +func (s SASCredential) MarshalJSON() ([]byte, error) { + type wrapper SASCredential + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SASCredential: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SASCredential: %+v", err) + } + + decoded["credentialType"] = "SAS" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SASCredential: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datareference/version.go b/resource-manager/machinelearningservices/2025-04-01/datareference/version.go new file mode 100644 index 00000000000..3944977b4af --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datareference/version.go @@ -0,0 +1,10 @@ +package datareference + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/datareference/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/README.md b/resource-manager/machinelearningservices/2025-04-01/datastore/README.md new file mode 100644 index 00000000000..1eb751eb94f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/README.md @@ -0,0 +1,106 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/datastore` Documentation + +The `datastore` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/datastore" +``` + + +### Client Initialization + +```go +client := datastore.NewDatastoreClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DatastoreClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := datastore.NewDataStoreID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataStoreName") + +payload := datastore.DatastoreResource{ + // ... +} + + +read, err := client.CreateOrUpdate(ctx, id, payload, datastore.DefaultCreateOrUpdateOperationOptions()) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DatastoreClient.Delete` + +```go +ctx := context.TODO() +id := datastore.NewDataStoreID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataStoreName") + +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: `DatastoreClient.Get` + +```go +ctx := context.TODO() +id := datastore.NewDataStoreID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataStoreName") + +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: `DatastoreClient.List` + +```go +ctx := context.TODO() +id := datastore.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +// alternatively `client.List(ctx, id, datastore.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, datastore.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DatastoreClient.ListSecrets` + +```go +ctx := context.TODO() +id := datastore.NewDataStoreID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataStoreName") + +read, err := client.ListSecrets(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/client.go b/resource-manager/machinelearningservices/2025-04-01/datastore/client.go new file mode 100644 index 00000000000..41a7b1da167 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/client.go @@ -0,0 +1,26 @@ +package datastore + +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 DatastoreClient struct { + Client *resourcemanager.Client +} + +func NewDatastoreClientWithBaseURI(sdkApi sdkEnv.Api) (*DatastoreClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "datastore", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DatastoreClient: %+v", err) + } + + return &DatastoreClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/constants.go b/resource-manager/machinelearningservices/2025-04-01/datastore/constants.go new file mode 100644 index 00000000000..2c540295402 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/constants.go @@ -0,0 +1,239 @@ +package datastore + +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 CredentialsType string + +const ( + CredentialsTypeAccountKey CredentialsType = "AccountKey" + CredentialsTypeCertificate CredentialsType = "Certificate" + CredentialsTypeNone CredentialsType = "None" + CredentialsTypeSas CredentialsType = "Sas" + CredentialsTypeServicePrincipal CredentialsType = "ServicePrincipal" +) + +func PossibleValuesForCredentialsType() []string { + return []string{ + string(CredentialsTypeAccountKey), + string(CredentialsTypeCertificate), + string(CredentialsTypeNone), + string(CredentialsTypeSas), + string(CredentialsTypeServicePrincipal), + } +} + +func (s *CredentialsType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCredentialsType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCredentialsType(input string) (*CredentialsType, error) { + vals := map[string]CredentialsType{ + "accountkey": CredentialsTypeAccountKey, + "certificate": CredentialsTypeCertificate, + "none": CredentialsTypeNone, + "sas": CredentialsTypeSas, + "serviceprincipal": CredentialsTypeServicePrincipal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CredentialsType(input) + return &out, nil +} + +type DatastoreType string + +const ( + DatastoreTypeAzureBlob DatastoreType = "AzureBlob" + DatastoreTypeAzureDataLakeGenOne DatastoreType = "AzureDataLakeGen1" + DatastoreTypeAzureDataLakeGenTwo DatastoreType = "AzureDataLakeGen2" + DatastoreTypeAzureFile DatastoreType = "AzureFile" + DatastoreTypeOneLake DatastoreType = "OneLake" +) + +func PossibleValuesForDatastoreType() []string { + return []string{ + string(DatastoreTypeAzureBlob), + string(DatastoreTypeAzureDataLakeGenOne), + string(DatastoreTypeAzureDataLakeGenTwo), + string(DatastoreTypeAzureFile), + string(DatastoreTypeOneLake), + } +} + +func (s *DatastoreType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDatastoreType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDatastoreType(input string) (*DatastoreType, error) { + vals := map[string]DatastoreType{ + "azureblob": DatastoreTypeAzureBlob, + "azuredatalakegen1": DatastoreTypeAzureDataLakeGenOne, + "azuredatalakegen2": DatastoreTypeAzureDataLakeGenTwo, + "azurefile": DatastoreTypeAzureFile, + "onelake": DatastoreTypeOneLake, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DatastoreType(input) + return &out, nil +} + +type OneLakeArtifactType string + +const ( + OneLakeArtifactTypeLakeHouse OneLakeArtifactType = "LakeHouse" +) + +func PossibleValuesForOneLakeArtifactType() []string { + return []string{ + string(OneLakeArtifactTypeLakeHouse), + } +} + +func (s *OneLakeArtifactType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOneLakeArtifactType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOneLakeArtifactType(input string) (*OneLakeArtifactType, error) { + vals := map[string]OneLakeArtifactType{ + "lakehouse": OneLakeArtifactTypeLakeHouse, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OneLakeArtifactType(input) + return &out, nil +} + +type SecretsType string + +const ( + SecretsTypeAccountKey SecretsType = "AccountKey" + SecretsTypeCertificate SecretsType = "Certificate" + SecretsTypeSas SecretsType = "Sas" + SecretsTypeServicePrincipal SecretsType = "ServicePrincipal" +) + +func PossibleValuesForSecretsType() []string { + return []string{ + string(SecretsTypeAccountKey), + string(SecretsTypeCertificate), + string(SecretsTypeSas), + string(SecretsTypeServicePrincipal), + } +} + +func (s *SecretsType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSecretsType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSecretsType(input string) (*SecretsType, error) { + vals := map[string]SecretsType{ + "accountkey": SecretsTypeAccountKey, + "certificate": SecretsTypeCertificate, + "sas": SecretsTypeSas, + "serviceprincipal": SecretsTypeServicePrincipal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SecretsType(input) + return &out, nil +} + +type ServiceDataAccessAuthIdentity string + +const ( + ServiceDataAccessAuthIdentityNone ServiceDataAccessAuthIdentity = "None" + ServiceDataAccessAuthIdentityWorkspaceSystemAssignedIdentity ServiceDataAccessAuthIdentity = "WorkspaceSystemAssignedIdentity" + ServiceDataAccessAuthIdentityWorkspaceUserAssignedIdentity ServiceDataAccessAuthIdentity = "WorkspaceUserAssignedIdentity" +) + +func PossibleValuesForServiceDataAccessAuthIdentity() []string { + return []string{ + string(ServiceDataAccessAuthIdentityNone), + string(ServiceDataAccessAuthIdentityWorkspaceSystemAssignedIdentity), + string(ServiceDataAccessAuthIdentityWorkspaceUserAssignedIdentity), + } +} + +func (s *ServiceDataAccessAuthIdentity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServiceDataAccessAuthIdentity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServiceDataAccessAuthIdentity(input string) (*ServiceDataAccessAuthIdentity, error) { + vals := map[string]ServiceDataAccessAuthIdentity{ + "none": ServiceDataAccessAuthIdentityNone, + "workspacesystemassignedidentity": ServiceDataAccessAuthIdentityWorkspaceSystemAssignedIdentity, + "workspaceuserassignedidentity": ServiceDataAccessAuthIdentityWorkspaceUserAssignedIdentity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServiceDataAccessAuthIdentity(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/id_datastore.go b/resource-manager/machinelearningservices/2025-04-01/datastore/id_datastore.go new file mode 100644 index 00000000000..1e813d33069 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/id_datastore.go @@ -0,0 +1,139 @@ +package datastore + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DataStoreId{}) +} + +var _ resourceids.ResourceId = &DataStoreId{} + +// DataStoreId is a struct representing the Resource ID for a Data Store +type DataStoreId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + DataStoreName string +} + +// NewDataStoreID returns a new DataStoreId struct +func NewDataStoreID(subscriptionId string, resourceGroupName string, workspaceName string, dataStoreName string) DataStoreId { + return DataStoreId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + DataStoreName: dataStoreName, + } +} + +// ParseDataStoreID parses 'input' into a DataStoreId +func ParseDataStoreID(input string) (*DataStoreId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataStoreId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataStoreId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDataStoreIDInsensitively parses 'input' case-insensitively into a DataStoreId +// note: this method should only be used for API response data and not user input +func ParseDataStoreIDInsensitively(input string) (*DataStoreId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataStoreId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataStoreId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DataStoreId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.DataStoreName, ok = input.Parsed["dataStoreName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dataStoreName", input) + } + + return nil +} + +// ValidateDataStoreID checks that 'input' can be parsed as a Data Store ID +func ValidateDataStoreID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseDataStoreID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Data Store ID +func (id DataStoreId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/dataStores/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.DataStoreName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Data Store ID +func (id DataStoreId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticDataStores", "dataStores", "dataStores"), + resourceids.UserSpecifiedSegment("dataStoreName", "dataStoreName"), + } +} + +// String returns a human-readable description of this Data Store ID +func (id DataStoreId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Data Store Name: %q", id.DataStoreName), + } + return fmt.Sprintf("Data Store (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/id_datastore_test.go b/resource-manager/machinelearningservices/2025-04-01/datastore/id_datastore_test.go new file mode 100644 index 00000000000..9a8ffedc957 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/id_datastore_test.go @@ -0,0 +1,327 @@ +package datastore + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DataStoreId{} + +func TestNewDataStoreID(t *testing.T) { + id := NewDataStoreID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataStoreName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.DataStoreName != "dataStoreName" { + t.Fatalf("Expected %q but got %q for Segment 'DataStoreName'", id.DataStoreName, "dataStoreName") + } +} + +func TestFormatDataStoreID(t *testing.T) { + actual := NewDataStoreID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataStoreName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/dataStores/dataStoreName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDataStoreID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataStoreId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/dataStores", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/dataStores/dataStoreName", + Expected: &DataStoreId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + DataStoreName: "dataStoreName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/dataStores/dataStoreName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataStoreID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.DataStoreName != v.Expected.DataStoreName { + t.Fatalf("Expected %q but got %q for DataStoreName", v.Expected.DataStoreName, actual.DataStoreName) + } + + } +} + +func TestParseDataStoreIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataStoreId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/dataStores", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/dAtAsToReS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/dataStores/dataStoreName", + Expected: &DataStoreId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + DataStoreName: "dataStoreName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/dataStores/dataStoreName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/dAtAsToReS/dAtAsToReNaMe", + Expected: &DataStoreId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + DataStoreName: "dAtAsToReNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/dAtAsToReS/dAtAsToReNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataStoreIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.DataStoreName != v.Expected.DataStoreName { + t.Fatalf("Expected %q but got %q for DataStoreName", v.Expected.DataStoreName, actual.DataStoreName) + } + + } +} + +func TestSegmentsForDataStoreId(t *testing.T) { + segments := DataStoreId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DataStoreId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/id_workspace.go b/resource-manager/machinelearningservices/2025-04-01/datastore/id_workspace.go new file mode 100644 index 00000000000..e2119eb3325 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/id_workspace.go @@ -0,0 +1,130 @@ +package datastore + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/id_workspace_test.go b/resource-manager/machinelearningservices/2025-04-01/datastore/id_workspace_test.go new file mode 100644 index 00000000000..7dc4b39c7b9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/id_workspace_test.go @@ -0,0 +1,282 @@ +package datastore + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/method_createorupdate.go b/resource-manager/machinelearningservices/2025-04-01/datastore/method_createorupdate.go new file mode 100644 index 00000000000..580889f1b17 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/method_createorupdate.go @@ -0,0 +1,88 @@ +package datastore + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *DatastoreResource +} + +type CreateOrUpdateOperationOptions struct { + SkipValidation *bool +} + +func DefaultCreateOrUpdateOperationOptions() CreateOrUpdateOperationOptions { + return CreateOrUpdateOperationOptions{} +} + +func (o CreateOrUpdateOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o CreateOrUpdateOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o CreateOrUpdateOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.SkipValidation != nil { + out.Append("skipValidation", fmt.Sprintf("%v", *o.SkipValidation)) + } + return &out +} + +// CreateOrUpdate ... +func (c DatastoreClient) CreateOrUpdate(ctx context.Context, id DataStoreId, input DatastoreResource, 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 + } + + var model DatastoreResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/method_delete.go b/resource-manager/machinelearningservices/2025-04-01/datastore/method_delete.go new file mode 100644 index 00000000000..82ff08fc795 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/method_delete.go @@ -0,0 +1,47 @@ +package datastore + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 DatastoreClient) Delete(ctx context.Context, id DataStoreId) (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/machinelearningservices/2025-04-01/datastore/method_get.go b/resource-manager/machinelearningservices/2025-04-01/datastore/method_get.go new file mode 100644 index 00000000000..b3fa29358b5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/method_get.go @@ -0,0 +1,53 @@ +package datastore + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *DatastoreResource +} + +// Get ... +func (c DatastoreClient) Get(ctx context.Context, id DataStoreId) (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 DatastoreResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/method_list.go b/resource-manager/machinelearningservices/2025-04-01/datastore/method_list.go new file mode 100644 index 00000000000..878ab24a9c3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/method_list.go @@ -0,0 +1,158 @@ +package datastore + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]DatastoreResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []DatastoreResource +} + +type ListOperationOptions struct { + Count *int64 + IsDefault *bool + Names *[]string + OrderBy *string + OrderByAsc *bool + SearchText *string + Skip *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.Count != nil { + out.Append("count", fmt.Sprintf("%v", *o.Count)) + } + if o.IsDefault != nil { + out.Append("isDefault", fmt.Sprintf("%v", *o.IsDefault)) + } + if o.Names != nil { + out.Append("names", fmt.Sprintf("%v", *o.Names)) + } + if o.OrderBy != nil { + out.Append("orderBy", fmt.Sprintf("%v", *o.OrderBy)) + } + if o.OrderByAsc != nil { + out.Append("orderByAsc", fmt.Sprintf("%v", *o.OrderByAsc)) + } + if o.SearchText != nil { + out.Append("searchText", fmt.Sprintf("%v", *o.SearchText)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + 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 DatastoreClient) List(ctx context.Context, id WorkspaceId, 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/dataStores", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DatastoreResource `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 DatastoreClient) ListComplete(ctx context.Context, id WorkspaceId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, DatastoreResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DatastoreClient) ListCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, options ListOperationOptions, predicate DatastoreResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]DatastoreResource, 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/machinelearningservices/2025-04-01/datastore/method_listsecrets.go b/resource-manager/machinelearningservices/2025-04-01/datastore/method_listsecrets.go new file mode 100644 index 00000000000..c96fe852b1c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/method_listsecrets.go @@ -0,0 +1,59 @@ +package datastore + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model DatastoreSecrets +} + +// ListSecrets ... +func (c DatastoreClient) ListSecrets(ctx context.Context, id DataStoreId) (result ListSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listSecrets", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var respObj json.RawMessage + if err = resp.Unmarshal(&respObj); err != nil { + return + } + model, err := UnmarshalDatastoreSecretsImplementation(respObj) + if err != nil { + return + } + result.Model = model + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/model_accountkeydatastorecredentials.go b/resource-manager/machinelearningservices/2025-04-01/datastore/model_accountkeydatastorecredentials.go new file mode 100644 index 00000000000..9e67a483305 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/model_accountkeydatastorecredentials.go @@ -0,0 +1,50 @@ +package datastore + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DatastoreCredentials = AccountKeyDatastoreCredentials{} + +type AccountKeyDatastoreCredentials struct { + Secrets AccountKeyDatastoreSecrets `json:"secrets"` + + // Fields inherited from DatastoreCredentials + + CredentialsType CredentialsType `json:"credentialsType"` +} + +func (s AccountKeyDatastoreCredentials) DatastoreCredentials() BaseDatastoreCredentialsImpl { + return BaseDatastoreCredentialsImpl{ + CredentialsType: s.CredentialsType, + } +} + +var _ json.Marshaler = AccountKeyDatastoreCredentials{} + +func (s AccountKeyDatastoreCredentials) MarshalJSON() ([]byte, error) { + type wrapper AccountKeyDatastoreCredentials + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AccountKeyDatastoreCredentials: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AccountKeyDatastoreCredentials: %+v", err) + } + + decoded["credentialsType"] = "AccountKey" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AccountKeyDatastoreCredentials: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/model_accountkeydatastoresecrets.go b/resource-manager/machinelearningservices/2025-04-01/datastore/model_accountkeydatastoresecrets.go new file mode 100644 index 00000000000..d20d7b0b312 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/model_accountkeydatastoresecrets.go @@ -0,0 +1,50 @@ +package datastore + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DatastoreSecrets = AccountKeyDatastoreSecrets{} + +type AccountKeyDatastoreSecrets struct { + Key *string `json:"key,omitempty"` + + // Fields inherited from DatastoreSecrets + + SecretsType SecretsType `json:"secretsType"` +} + +func (s AccountKeyDatastoreSecrets) DatastoreSecrets() BaseDatastoreSecretsImpl { + return BaseDatastoreSecretsImpl{ + SecretsType: s.SecretsType, + } +} + +var _ json.Marshaler = AccountKeyDatastoreSecrets{} + +func (s AccountKeyDatastoreSecrets) MarshalJSON() ([]byte, error) { + type wrapper AccountKeyDatastoreSecrets + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AccountKeyDatastoreSecrets: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AccountKeyDatastoreSecrets: %+v", err) + } + + decoded["secretsType"] = "AccountKey" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AccountKeyDatastoreSecrets: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/model_azureblobdatastore.go b/resource-manager/machinelearningservices/2025-04-01/datastore/model_azureblobdatastore.go new file mode 100644 index 00000000000..b19f553f1e6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/model_azureblobdatastore.go @@ -0,0 +1,116 @@ +package datastore + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Datastore = AzureBlobDatastore{} + +type AzureBlobDatastore struct { + AccountName *string `json:"accountName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + Endpoint *string `json:"endpoint,omitempty"` + Protocol *string `json:"protocol,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + ServiceDataAccessAuthIdentity *ServiceDataAccessAuthIdentity `json:"serviceDataAccessAuthIdentity,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + + // Fields inherited from Datastore + + Credentials DatastoreCredentials `json:"credentials"` + DatastoreType DatastoreType `json:"datastoreType"` + Description *string `json:"description,omitempty"` + IsDefault *bool `json:"isDefault,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +func (s AzureBlobDatastore) Datastore() BaseDatastoreImpl { + return BaseDatastoreImpl{ + Credentials: s.Credentials, + DatastoreType: s.DatastoreType, + Description: s.Description, + IsDefault: s.IsDefault, + Properties: s.Properties, + Tags: s.Tags, + } +} + +var _ json.Marshaler = AzureBlobDatastore{} + +func (s AzureBlobDatastore) MarshalJSON() ([]byte, error) { + type wrapper AzureBlobDatastore + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureBlobDatastore: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureBlobDatastore: %+v", err) + } + + decoded["datastoreType"] = "AzureBlob" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureBlobDatastore: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &AzureBlobDatastore{} + +func (s *AzureBlobDatastore) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AccountName *string `json:"accountName,omitempty"` + ContainerName *string `json:"containerName,omitempty"` + Endpoint *string `json:"endpoint,omitempty"` + Protocol *string `json:"protocol,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + ServiceDataAccessAuthIdentity *ServiceDataAccessAuthIdentity `json:"serviceDataAccessAuthIdentity,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + DatastoreType DatastoreType `json:"datastoreType"` + Description *string `json:"description,omitempty"` + IsDefault *bool `json:"isDefault,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AccountName = decoded.AccountName + s.ContainerName = decoded.ContainerName + s.Endpoint = decoded.Endpoint + s.Protocol = decoded.Protocol + s.ResourceGroup = decoded.ResourceGroup + s.ServiceDataAccessAuthIdentity = decoded.ServiceDataAccessAuthIdentity + s.SubscriptionId = decoded.SubscriptionId + s.DatastoreType = decoded.DatastoreType + s.Description = decoded.Description + s.IsDefault = decoded.IsDefault + s.Properties = decoded.Properties + s.Tags = decoded.Tags + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AzureBlobDatastore into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["credentials"]; ok { + impl, err := UnmarshalDatastoreCredentialsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Credentials' for 'AzureBlobDatastore': %+v", err) + } + s.Credentials = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/model_azuredatalakegen1datastore.go b/resource-manager/machinelearningservices/2025-04-01/datastore/model_azuredatalakegen1datastore.go new file mode 100644 index 00000000000..fef6abd7772 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/model_azuredatalakegen1datastore.go @@ -0,0 +1,107 @@ +package datastore + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Datastore = AzureDataLakeGen1Datastore{} + +type AzureDataLakeGen1Datastore struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + ServiceDataAccessAuthIdentity *ServiceDataAccessAuthIdentity `json:"serviceDataAccessAuthIdentity,omitempty"` + StoreName string `json:"storeName"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + + // Fields inherited from Datastore + + Credentials DatastoreCredentials `json:"credentials"` + DatastoreType DatastoreType `json:"datastoreType"` + Description *string `json:"description,omitempty"` + IsDefault *bool `json:"isDefault,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +func (s AzureDataLakeGen1Datastore) Datastore() BaseDatastoreImpl { + return BaseDatastoreImpl{ + Credentials: s.Credentials, + DatastoreType: s.DatastoreType, + Description: s.Description, + IsDefault: s.IsDefault, + Properties: s.Properties, + Tags: s.Tags, + } +} + +var _ json.Marshaler = AzureDataLakeGen1Datastore{} + +func (s AzureDataLakeGen1Datastore) MarshalJSON() ([]byte, error) { + type wrapper AzureDataLakeGen1Datastore + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureDataLakeGen1Datastore: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureDataLakeGen1Datastore: %+v", err) + } + + decoded["datastoreType"] = "AzureDataLakeGen1" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureDataLakeGen1Datastore: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &AzureDataLakeGen1Datastore{} + +func (s *AzureDataLakeGen1Datastore) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ResourceGroup *string `json:"resourceGroup,omitempty"` + ServiceDataAccessAuthIdentity *ServiceDataAccessAuthIdentity `json:"serviceDataAccessAuthIdentity,omitempty"` + StoreName string `json:"storeName"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + DatastoreType DatastoreType `json:"datastoreType"` + Description *string `json:"description,omitempty"` + IsDefault *bool `json:"isDefault,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ResourceGroup = decoded.ResourceGroup + s.ServiceDataAccessAuthIdentity = decoded.ServiceDataAccessAuthIdentity + s.StoreName = decoded.StoreName + s.SubscriptionId = decoded.SubscriptionId + s.DatastoreType = decoded.DatastoreType + s.Description = decoded.Description + s.IsDefault = decoded.IsDefault + s.Properties = decoded.Properties + s.Tags = decoded.Tags + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AzureDataLakeGen1Datastore into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["credentials"]; ok { + impl, err := UnmarshalDatastoreCredentialsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Credentials' for 'AzureDataLakeGen1Datastore': %+v", err) + } + s.Credentials = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/model_azuredatalakegen2datastore.go b/resource-manager/machinelearningservices/2025-04-01/datastore/model_azuredatalakegen2datastore.go new file mode 100644 index 00000000000..9c7e1643881 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/model_azuredatalakegen2datastore.go @@ -0,0 +1,116 @@ +package datastore + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Datastore = AzureDataLakeGen2Datastore{} + +type AzureDataLakeGen2Datastore struct { + AccountName string `json:"accountName"` + Endpoint *string `json:"endpoint,omitempty"` + Filesystem string `json:"filesystem"` + Protocol *string `json:"protocol,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + ServiceDataAccessAuthIdentity *ServiceDataAccessAuthIdentity `json:"serviceDataAccessAuthIdentity,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + + // Fields inherited from Datastore + + Credentials DatastoreCredentials `json:"credentials"` + DatastoreType DatastoreType `json:"datastoreType"` + Description *string `json:"description,omitempty"` + IsDefault *bool `json:"isDefault,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +func (s AzureDataLakeGen2Datastore) Datastore() BaseDatastoreImpl { + return BaseDatastoreImpl{ + Credentials: s.Credentials, + DatastoreType: s.DatastoreType, + Description: s.Description, + IsDefault: s.IsDefault, + Properties: s.Properties, + Tags: s.Tags, + } +} + +var _ json.Marshaler = AzureDataLakeGen2Datastore{} + +func (s AzureDataLakeGen2Datastore) MarshalJSON() ([]byte, error) { + type wrapper AzureDataLakeGen2Datastore + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureDataLakeGen2Datastore: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureDataLakeGen2Datastore: %+v", err) + } + + decoded["datastoreType"] = "AzureDataLakeGen2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureDataLakeGen2Datastore: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &AzureDataLakeGen2Datastore{} + +func (s *AzureDataLakeGen2Datastore) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AccountName string `json:"accountName"` + Endpoint *string `json:"endpoint,omitempty"` + Filesystem string `json:"filesystem"` + Protocol *string `json:"protocol,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + ServiceDataAccessAuthIdentity *ServiceDataAccessAuthIdentity `json:"serviceDataAccessAuthIdentity,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + DatastoreType DatastoreType `json:"datastoreType"` + Description *string `json:"description,omitempty"` + IsDefault *bool `json:"isDefault,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AccountName = decoded.AccountName + s.Endpoint = decoded.Endpoint + s.Filesystem = decoded.Filesystem + s.Protocol = decoded.Protocol + s.ResourceGroup = decoded.ResourceGroup + s.ServiceDataAccessAuthIdentity = decoded.ServiceDataAccessAuthIdentity + s.SubscriptionId = decoded.SubscriptionId + s.DatastoreType = decoded.DatastoreType + s.Description = decoded.Description + s.IsDefault = decoded.IsDefault + s.Properties = decoded.Properties + s.Tags = decoded.Tags + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AzureDataLakeGen2Datastore into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["credentials"]; ok { + impl, err := UnmarshalDatastoreCredentialsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Credentials' for 'AzureDataLakeGen2Datastore': %+v", err) + } + s.Credentials = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/model_azurefiledatastore.go b/resource-manager/machinelearningservices/2025-04-01/datastore/model_azurefiledatastore.go new file mode 100644 index 00000000000..1a0a199e3c3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/model_azurefiledatastore.go @@ -0,0 +1,116 @@ +package datastore + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Datastore = AzureFileDatastore{} + +type AzureFileDatastore struct { + AccountName string `json:"accountName"` + Endpoint *string `json:"endpoint,omitempty"` + FileShareName string `json:"fileShareName"` + Protocol *string `json:"protocol,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + ServiceDataAccessAuthIdentity *ServiceDataAccessAuthIdentity `json:"serviceDataAccessAuthIdentity,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + + // Fields inherited from Datastore + + Credentials DatastoreCredentials `json:"credentials"` + DatastoreType DatastoreType `json:"datastoreType"` + Description *string `json:"description,omitempty"` + IsDefault *bool `json:"isDefault,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +func (s AzureFileDatastore) Datastore() BaseDatastoreImpl { + return BaseDatastoreImpl{ + Credentials: s.Credentials, + DatastoreType: s.DatastoreType, + Description: s.Description, + IsDefault: s.IsDefault, + Properties: s.Properties, + Tags: s.Tags, + } +} + +var _ json.Marshaler = AzureFileDatastore{} + +func (s AzureFileDatastore) MarshalJSON() ([]byte, error) { + type wrapper AzureFileDatastore + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureFileDatastore: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureFileDatastore: %+v", err) + } + + decoded["datastoreType"] = "AzureFile" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureFileDatastore: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &AzureFileDatastore{} + +func (s *AzureFileDatastore) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AccountName string `json:"accountName"` + Endpoint *string `json:"endpoint,omitempty"` + FileShareName string `json:"fileShareName"` + Protocol *string `json:"protocol,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + ServiceDataAccessAuthIdentity *ServiceDataAccessAuthIdentity `json:"serviceDataAccessAuthIdentity,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + DatastoreType DatastoreType `json:"datastoreType"` + Description *string `json:"description,omitempty"` + IsDefault *bool `json:"isDefault,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AccountName = decoded.AccountName + s.Endpoint = decoded.Endpoint + s.FileShareName = decoded.FileShareName + s.Protocol = decoded.Protocol + s.ResourceGroup = decoded.ResourceGroup + s.ServiceDataAccessAuthIdentity = decoded.ServiceDataAccessAuthIdentity + s.SubscriptionId = decoded.SubscriptionId + s.DatastoreType = decoded.DatastoreType + s.Description = decoded.Description + s.IsDefault = decoded.IsDefault + s.Properties = decoded.Properties + s.Tags = decoded.Tags + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AzureFileDatastore into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["credentials"]; ok { + impl, err := UnmarshalDatastoreCredentialsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Credentials' for 'AzureFileDatastore': %+v", err) + } + s.Credentials = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/model_certificatedatastorecredentials.go b/resource-manager/machinelearningservices/2025-04-01/datastore/model_certificatedatastorecredentials.go new file mode 100644 index 00000000000..58e11c2fd76 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/model_certificatedatastorecredentials.go @@ -0,0 +1,55 @@ +package datastore + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DatastoreCredentials = CertificateDatastoreCredentials{} + +type CertificateDatastoreCredentials struct { + AuthorityURL *string `json:"authorityUrl,omitempty"` + ClientId string `json:"clientId"` + ResourceURL *string `json:"resourceUrl,omitempty"` + Secrets CertificateDatastoreSecrets `json:"secrets"` + TenantId string `json:"tenantId"` + Thumbprint string `json:"thumbprint"` + + // Fields inherited from DatastoreCredentials + + CredentialsType CredentialsType `json:"credentialsType"` +} + +func (s CertificateDatastoreCredentials) DatastoreCredentials() BaseDatastoreCredentialsImpl { + return BaseDatastoreCredentialsImpl{ + CredentialsType: s.CredentialsType, + } +} + +var _ json.Marshaler = CertificateDatastoreCredentials{} + +func (s CertificateDatastoreCredentials) MarshalJSON() ([]byte, error) { + type wrapper CertificateDatastoreCredentials + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CertificateDatastoreCredentials: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CertificateDatastoreCredentials: %+v", err) + } + + decoded["credentialsType"] = "Certificate" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CertificateDatastoreCredentials: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/model_certificatedatastoresecrets.go b/resource-manager/machinelearningservices/2025-04-01/datastore/model_certificatedatastoresecrets.go new file mode 100644 index 00000000000..46a603c5fb1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/model_certificatedatastoresecrets.go @@ -0,0 +1,50 @@ +package datastore + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DatastoreSecrets = CertificateDatastoreSecrets{} + +type CertificateDatastoreSecrets struct { + Certificate *string `json:"certificate,omitempty"` + + // Fields inherited from DatastoreSecrets + + SecretsType SecretsType `json:"secretsType"` +} + +func (s CertificateDatastoreSecrets) DatastoreSecrets() BaseDatastoreSecretsImpl { + return BaseDatastoreSecretsImpl{ + SecretsType: s.SecretsType, + } +} + +var _ json.Marshaler = CertificateDatastoreSecrets{} + +func (s CertificateDatastoreSecrets) MarshalJSON() ([]byte, error) { + type wrapper CertificateDatastoreSecrets + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CertificateDatastoreSecrets: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CertificateDatastoreSecrets: %+v", err) + } + + decoded["secretsType"] = "Certificate" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CertificateDatastoreSecrets: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/model_datastore.go b/resource-manager/machinelearningservices/2025-04-01/datastore/model_datastore.go new file mode 100644 index 00000000000..e59f7b3f870 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/model_datastore.go @@ -0,0 +1,148 @@ +package datastore + +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 Datastore interface { + Datastore() BaseDatastoreImpl +} + +var _ Datastore = BaseDatastoreImpl{} + +type BaseDatastoreImpl struct { + Credentials DatastoreCredentials `json:"credentials"` + DatastoreType DatastoreType `json:"datastoreType"` + Description *string `json:"description,omitempty"` + IsDefault *bool `json:"isDefault,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +func (s BaseDatastoreImpl) Datastore() BaseDatastoreImpl { + return s +} + +var _ Datastore = RawDatastoreImpl{} + +// RawDatastoreImpl 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 RawDatastoreImpl struct { + datastore BaseDatastoreImpl + Type string + Values map[string]interface{} +} + +func (s RawDatastoreImpl) Datastore() BaseDatastoreImpl { + return s.datastore +} + +var _ json.Unmarshaler = &BaseDatastoreImpl{} + +func (s *BaseDatastoreImpl) UnmarshalJSON(bytes []byte) error { + var decoded struct { + DatastoreType DatastoreType `json:"datastoreType"` + Description *string `json:"description,omitempty"` + IsDefault *bool `json:"isDefault,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.DatastoreType = decoded.DatastoreType + s.Description = decoded.Description + s.IsDefault = decoded.IsDefault + s.Properties = decoded.Properties + s.Tags = decoded.Tags + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling BaseDatastoreImpl into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["credentials"]; ok { + impl, err := UnmarshalDatastoreCredentialsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Credentials' for 'BaseDatastoreImpl': %+v", err) + } + s.Credentials = impl + } + + return nil +} + +func UnmarshalDatastoreImplementation(input []byte) (Datastore, 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 Datastore into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["datastoreType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AzureBlob") { + var out AzureBlobDatastore + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureBlobDatastore: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureDataLakeGen1") { + var out AzureDataLakeGen1Datastore + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureDataLakeGen1Datastore: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureDataLakeGen2") { + var out AzureDataLakeGen2Datastore + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureDataLakeGen2Datastore: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AzureFile") { + var out AzureFileDatastore + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureFileDatastore: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "OneLake") { + var out OneLakeDatastore + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into OneLakeDatastore: %+v", err) + } + return out, nil + } + + var parent BaseDatastoreImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseDatastoreImpl: %+v", err) + } + + return RawDatastoreImpl{ + datastore: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/model_datastorecredentials.go b/resource-manager/machinelearningservices/2025-04-01/datastore/model_datastorecredentials.go new file mode 100644 index 00000000000..ce1130b5e23 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/model_datastorecredentials.go @@ -0,0 +1,107 @@ +package datastore + +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 DatastoreCredentials interface { + DatastoreCredentials() BaseDatastoreCredentialsImpl +} + +var _ DatastoreCredentials = BaseDatastoreCredentialsImpl{} + +type BaseDatastoreCredentialsImpl struct { + CredentialsType CredentialsType `json:"credentialsType"` +} + +func (s BaseDatastoreCredentialsImpl) DatastoreCredentials() BaseDatastoreCredentialsImpl { + return s +} + +var _ DatastoreCredentials = RawDatastoreCredentialsImpl{} + +// RawDatastoreCredentialsImpl 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 RawDatastoreCredentialsImpl struct { + datastoreCredentials BaseDatastoreCredentialsImpl + Type string + Values map[string]interface{} +} + +func (s RawDatastoreCredentialsImpl) DatastoreCredentials() BaseDatastoreCredentialsImpl { + return s.datastoreCredentials +} + +func UnmarshalDatastoreCredentialsImplementation(input []byte) (DatastoreCredentials, 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 DatastoreCredentials into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["credentialsType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AccountKey") { + var out AccountKeyDatastoreCredentials + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AccountKeyDatastoreCredentials: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Certificate") { + var out CertificateDatastoreCredentials + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CertificateDatastoreCredentials: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "None") { + var out NoneDatastoreCredentials + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into NoneDatastoreCredentials: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Sas") { + var out SasDatastoreCredentials + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SasDatastoreCredentials: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ServicePrincipal") { + var out ServicePrincipalDatastoreCredentials + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ServicePrincipalDatastoreCredentials: %+v", err) + } + return out, nil + } + + var parent BaseDatastoreCredentialsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseDatastoreCredentialsImpl: %+v", err) + } + + return RawDatastoreCredentialsImpl{ + datastoreCredentials: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/model_datastoreresource.go b/resource-manager/machinelearningservices/2025-04-01/datastore/model_datastoreresource.go new file mode 100644 index 00000000000..d1ab2d2dcbf --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/model_datastoreresource.go @@ -0,0 +1,53 @@ +package datastore + +import ( + "encoding/json" + "fmt" + + "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 DatastoreResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties Datastore `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &DatastoreResource{} + +func (s *DatastoreResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Id = decoded.Id + s.Name = decoded.Name + s.SystemData = decoded.SystemData + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling DatastoreResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalDatastoreImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'DatastoreResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/model_datastoresecrets.go b/resource-manager/machinelearningservices/2025-04-01/datastore/model_datastoresecrets.go new file mode 100644 index 00000000000..41a62c87eb4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/model_datastoresecrets.go @@ -0,0 +1,99 @@ +package datastore + +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 DatastoreSecrets interface { + DatastoreSecrets() BaseDatastoreSecretsImpl +} + +var _ DatastoreSecrets = BaseDatastoreSecretsImpl{} + +type BaseDatastoreSecretsImpl struct { + SecretsType SecretsType `json:"secretsType"` +} + +func (s BaseDatastoreSecretsImpl) DatastoreSecrets() BaseDatastoreSecretsImpl { + return s +} + +var _ DatastoreSecrets = RawDatastoreSecretsImpl{} + +// RawDatastoreSecretsImpl 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 RawDatastoreSecretsImpl struct { + datastoreSecrets BaseDatastoreSecretsImpl + Type string + Values map[string]interface{} +} + +func (s RawDatastoreSecretsImpl) DatastoreSecrets() BaseDatastoreSecretsImpl { + return s.datastoreSecrets +} + +func UnmarshalDatastoreSecretsImplementation(input []byte) (DatastoreSecrets, 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 DatastoreSecrets into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["secretsType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AccountKey") { + var out AccountKeyDatastoreSecrets + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AccountKeyDatastoreSecrets: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Certificate") { + var out CertificateDatastoreSecrets + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CertificateDatastoreSecrets: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Sas") { + var out SasDatastoreSecrets + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SasDatastoreSecrets: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ServicePrincipal") { + var out ServicePrincipalDatastoreSecrets + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ServicePrincipalDatastoreSecrets: %+v", err) + } + return out, nil + } + + var parent BaseDatastoreSecretsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseDatastoreSecretsImpl: %+v", err) + } + + return RawDatastoreSecretsImpl{ + datastoreSecrets: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/model_lakehouseartifact.go b/resource-manager/machinelearningservices/2025-04-01/datastore/model_lakehouseartifact.go new file mode 100644 index 00000000000..63f49f8b1c1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/model_lakehouseartifact.go @@ -0,0 +1,51 @@ +package datastore + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ OneLakeArtifact = LakeHouseArtifact{} + +type LakeHouseArtifact struct { + + // Fields inherited from OneLakeArtifact + + ArtifactName string `json:"artifactName"` + ArtifactType OneLakeArtifactType `json:"artifactType"` +} + +func (s LakeHouseArtifact) OneLakeArtifact() BaseOneLakeArtifactImpl { + return BaseOneLakeArtifactImpl{ + ArtifactName: s.ArtifactName, + ArtifactType: s.ArtifactType, + } +} + +var _ json.Marshaler = LakeHouseArtifact{} + +func (s LakeHouseArtifact) MarshalJSON() ([]byte, error) { + type wrapper LakeHouseArtifact + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling LakeHouseArtifact: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling LakeHouseArtifact: %+v", err) + } + + decoded["artifactType"] = "LakeHouse" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling LakeHouseArtifact: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/model_nonedatastorecredentials.go b/resource-manager/machinelearningservices/2025-04-01/datastore/model_nonedatastorecredentials.go new file mode 100644 index 00000000000..91781358c66 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/model_nonedatastorecredentials.go @@ -0,0 +1,49 @@ +package datastore + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DatastoreCredentials = NoneDatastoreCredentials{} + +type NoneDatastoreCredentials struct { + + // Fields inherited from DatastoreCredentials + + CredentialsType CredentialsType `json:"credentialsType"` +} + +func (s NoneDatastoreCredentials) DatastoreCredentials() BaseDatastoreCredentialsImpl { + return BaseDatastoreCredentialsImpl{ + CredentialsType: s.CredentialsType, + } +} + +var _ json.Marshaler = NoneDatastoreCredentials{} + +func (s NoneDatastoreCredentials) MarshalJSON() ([]byte, error) { + type wrapper NoneDatastoreCredentials + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling NoneDatastoreCredentials: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling NoneDatastoreCredentials: %+v", err) + } + + decoded["credentialsType"] = "None" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling NoneDatastoreCredentials: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/model_onelakeartifact.go b/resource-manager/machinelearningservices/2025-04-01/datastore/model_onelakeartifact.go new file mode 100644 index 00000000000..243f8c717d1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/model_onelakeartifact.go @@ -0,0 +1,76 @@ +package datastore + +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 OneLakeArtifact interface { + OneLakeArtifact() BaseOneLakeArtifactImpl +} + +var _ OneLakeArtifact = BaseOneLakeArtifactImpl{} + +type BaseOneLakeArtifactImpl struct { + ArtifactName string `json:"artifactName"` + ArtifactType OneLakeArtifactType `json:"artifactType"` +} + +func (s BaseOneLakeArtifactImpl) OneLakeArtifact() BaseOneLakeArtifactImpl { + return s +} + +var _ OneLakeArtifact = RawOneLakeArtifactImpl{} + +// RawOneLakeArtifactImpl 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 RawOneLakeArtifactImpl struct { + oneLakeArtifact BaseOneLakeArtifactImpl + Type string + Values map[string]interface{} +} + +func (s RawOneLakeArtifactImpl) OneLakeArtifact() BaseOneLakeArtifactImpl { + return s.oneLakeArtifact +} + +func UnmarshalOneLakeArtifactImplementation(input []byte) (OneLakeArtifact, 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 OneLakeArtifact into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["artifactType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "LakeHouse") { + var out LakeHouseArtifact + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into LakeHouseArtifact: %+v", err) + } + return out, nil + } + + var parent BaseOneLakeArtifactImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseOneLakeArtifactImpl: %+v", err) + } + + return RawOneLakeArtifactImpl{ + oneLakeArtifact: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/model_onelakedatastore.go b/resource-manager/machinelearningservices/2025-04-01/datastore/model_onelakedatastore.go new file mode 100644 index 00000000000..255277e4911 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/model_onelakedatastore.go @@ -0,0 +1,113 @@ +package datastore + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Datastore = OneLakeDatastore{} + +type OneLakeDatastore struct { + Artifact OneLakeArtifact `json:"artifact"` + Endpoint *string `json:"endpoint,omitempty"` + OneLakeWorkspaceName string `json:"oneLakeWorkspaceName"` + ServiceDataAccessAuthIdentity *ServiceDataAccessAuthIdentity `json:"serviceDataAccessAuthIdentity,omitempty"` + + // Fields inherited from Datastore + + Credentials DatastoreCredentials `json:"credentials"` + DatastoreType DatastoreType `json:"datastoreType"` + Description *string `json:"description,omitempty"` + IsDefault *bool `json:"isDefault,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +func (s OneLakeDatastore) Datastore() BaseDatastoreImpl { + return BaseDatastoreImpl{ + Credentials: s.Credentials, + DatastoreType: s.DatastoreType, + Description: s.Description, + IsDefault: s.IsDefault, + Properties: s.Properties, + Tags: s.Tags, + } +} + +var _ json.Marshaler = OneLakeDatastore{} + +func (s OneLakeDatastore) MarshalJSON() ([]byte, error) { + type wrapper OneLakeDatastore + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling OneLakeDatastore: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling OneLakeDatastore: %+v", err) + } + + decoded["datastoreType"] = "OneLake" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling OneLakeDatastore: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &OneLakeDatastore{} + +func (s *OneLakeDatastore) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Endpoint *string `json:"endpoint,omitempty"` + OneLakeWorkspaceName string `json:"oneLakeWorkspaceName"` + ServiceDataAccessAuthIdentity *ServiceDataAccessAuthIdentity `json:"serviceDataAccessAuthIdentity,omitempty"` + DatastoreType DatastoreType `json:"datastoreType"` + Description *string `json:"description,omitempty"` + IsDefault *bool `json:"isDefault,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Endpoint = decoded.Endpoint + s.OneLakeWorkspaceName = decoded.OneLakeWorkspaceName + s.ServiceDataAccessAuthIdentity = decoded.ServiceDataAccessAuthIdentity + s.DatastoreType = decoded.DatastoreType + s.Description = decoded.Description + s.IsDefault = decoded.IsDefault + s.Properties = decoded.Properties + s.Tags = decoded.Tags + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling OneLakeDatastore into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["artifact"]; ok { + impl, err := UnmarshalOneLakeArtifactImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Artifact' for 'OneLakeDatastore': %+v", err) + } + s.Artifact = impl + } + + if v, ok := temp["credentials"]; ok { + impl, err := UnmarshalDatastoreCredentialsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Credentials' for 'OneLakeDatastore': %+v", err) + } + s.Credentials = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/model_sasdatastorecredentials.go b/resource-manager/machinelearningservices/2025-04-01/datastore/model_sasdatastorecredentials.go new file mode 100644 index 00000000000..a2ddc25f4b7 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/model_sasdatastorecredentials.go @@ -0,0 +1,50 @@ +package datastore + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DatastoreCredentials = SasDatastoreCredentials{} + +type SasDatastoreCredentials struct { + Secrets SasDatastoreSecrets `json:"secrets"` + + // Fields inherited from DatastoreCredentials + + CredentialsType CredentialsType `json:"credentialsType"` +} + +func (s SasDatastoreCredentials) DatastoreCredentials() BaseDatastoreCredentialsImpl { + return BaseDatastoreCredentialsImpl{ + CredentialsType: s.CredentialsType, + } +} + +var _ json.Marshaler = SasDatastoreCredentials{} + +func (s SasDatastoreCredentials) MarshalJSON() ([]byte, error) { + type wrapper SasDatastoreCredentials + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SasDatastoreCredentials: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SasDatastoreCredentials: %+v", err) + } + + decoded["credentialsType"] = "Sas" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SasDatastoreCredentials: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/model_sasdatastoresecrets.go b/resource-manager/machinelearningservices/2025-04-01/datastore/model_sasdatastoresecrets.go new file mode 100644 index 00000000000..bf5cac042a7 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/model_sasdatastoresecrets.go @@ -0,0 +1,50 @@ +package datastore + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DatastoreSecrets = SasDatastoreSecrets{} + +type SasDatastoreSecrets struct { + SasToken *string `json:"sasToken,omitempty"` + + // Fields inherited from DatastoreSecrets + + SecretsType SecretsType `json:"secretsType"` +} + +func (s SasDatastoreSecrets) DatastoreSecrets() BaseDatastoreSecretsImpl { + return BaseDatastoreSecretsImpl{ + SecretsType: s.SecretsType, + } +} + +var _ json.Marshaler = SasDatastoreSecrets{} + +func (s SasDatastoreSecrets) MarshalJSON() ([]byte, error) { + type wrapper SasDatastoreSecrets + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SasDatastoreSecrets: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SasDatastoreSecrets: %+v", err) + } + + decoded["secretsType"] = "Sas" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SasDatastoreSecrets: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/model_serviceprincipaldatastorecredentials.go b/resource-manager/machinelearningservices/2025-04-01/datastore/model_serviceprincipaldatastorecredentials.go new file mode 100644 index 00000000000..d53386d94ae --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/model_serviceprincipaldatastorecredentials.go @@ -0,0 +1,54 @@ +package datastore + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DatastoreCredentials = ServicePrincipalDatastoreCredentials{} + +type ServicePrincipalDatastoreCredentials struct { + AuthorityURL *string `json:"authorityUrl,omitempty"` + ClientId string `json:"clientId"` + ResourceURL *string `json:"resourceUrl,omitempty"` + Secrets ServicePrincipalDatastoreSecrets `json:"secrets"` + TenantId string `json:"tenantId"` + + // Fields inherited from DatastoreCredentials + + CredentialsType CredentialsType `json:"credentialsType"` +} + +func (s ServicePrincipalDatastoreCredentials) DatastoreCredentials() BaseDatastoreCredentialsImpl { + return BaseDatastoreCredentialsImpl{ + CredentialsType: s.CredentialsType, + } +} + +var _ json.Marshaler = ServicePrincipalDatastoreCredentials{} + +func (s ServicePrincipalDatastoreCredentials) MarshalJSON() ([]byte, error) { + type wrapper ServicePrincipalDatastoreCredentials + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ServicePrincipalDatastoreCredentials: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ServicePrincipalDatastoreCredentials: %+v", err) + } + + decoded["credentialsType"] = "ServicePrincipal" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ServicePrincipalDatastoreCredentials: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/model_serviceprincipaldatastoresecrets.go b/resource-manager/machinelearningservices/2025-04-01/datastore/model_serviceprincipaldatastoresecrets.go new file mode 100644 index 00000000000..e7767ab1806 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/model_serviceprincipaldatastoresecrets.go @@ -0,0 +1,50 @@ +package datastore + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DatastoreSecrets = ServicePrincipalDatastoreSecrets{} + +type ServicePrincipalDatastoreSecrets struct { + ClientSecret *string `json:"clientSecret,omitempty"` + + // Fields inherited from DatastoreSecrets + + SecretsType SecretsType `json:"secretsType"` +} + +func (s ServicePrincipalDatastoreSecrets) DatastoreSecrets() BaseDatastoreSecretsImpl { + return BaseDatastoreSecretsImpl{ + SecretsType: s.SecretsType, + } +} + +var _ json.Marshaler = ServicePrincipalDatastoreSecrets{} + +func (s ServicePrincipalDatastoreSecrets) MarshalJSON() ([]byte, error) { + type wrapper ServicePrincipalDatastoreSecrets + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ServicePrincipalDatastoreSecrets: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ServicePrincipalDatastoreSecrets: %+v", err) + } + + decoded["secretsType"] = "ServicePrincipal" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ServicePrincipalDatastoreSecrets: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/datastore/predicates.go b/resource-manager/machinelearningservices/2025-04-01/datastore/predicates.go new file mode 100644 index 00000000000..174b0d437dd --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/predicates.go @@ -0,0 +1,27 @@ +package datastore + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatastoreResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p DatastoreResourceOperationPredicate) Matches(input DatastoreResource) 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/machinelearningservices/2025-04-01/datastore/version.go b/resource-manager/machinelearningservices/2025-04-01/datastore/version.go new file mode 100644 index 00000000000..fa4d93933c2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/datastore/version.go @@ -0,0 +1,10 @@ +package datastore + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/datastore/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversion/README.md b/resource-manager/machinelearningservices/2025-04-01/dataversion/README.md new file mode 100644 index 00000000000..edb0a0fb8cc --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversion/README.md @@ -0,0 +1,107 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/dataversion` Documentation + +The `dataversion` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/dataversion" +``` + + +### Client Initialization + +```go +client := dataversion.NewDataVersionClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DataVersionClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := dataversion.NewDataVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataName", "versionName") + +payload := dataversion.DataVersionBaseResource{ + // ... +} + + +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: `DataVersionClient.Delete` + +```go +ctx := context.TODO() +id := dataversion.NewDataVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataName", "versionName") + +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: `DataVersionClient.Get` + +```go +ctx := context.TODO() +id := dataversion.NewDataVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataName", "versionName") + +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: `DataVersionClient.List` + +```go +ctx := context.TODO() +id := dataversion.NewWorkspaceDataID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataName") + +// alternatively `client.List(ctx, id, dataversion.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, dataversion.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `DataVersionClient.Publish` + +```go +ctx := context.TODO() +id := dataversion.NewDataVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataName", "versionName") + +payload := dataversion.DestinationAsset{ + // ... +} + + +if err := client.PublishThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversion/client.go b/resource-manager/machinelearningservices/2025-04-01/dataversion/client.go new file mode 100644 index 00000000000..5378de1013a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversion/client.go @@ -0,0 +1,26 @@ +package dataversion + +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 DataVersionClient struct { + Client *resourcemanager.Client +} + +func NewDataVersionClientWithBaseURI(sdkApi sdkEnv.Api) (*DataVersionClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "dataversion", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DataVersionClient: %+v", err) + } + + return &DataVersionClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversion/constants.go b/resource-manager/machinelearningservices/2025-04-01/dataversion/constants.go new file mode 100644 index 00000000000..adf252865db --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversion/constants.go @@ -0,0 +1,98 @@ +package dataversion + +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 DataType string + +const ( + DataTypeMltable DataType = "mltable" + DataTypeUriFile DataType = "uri_file" + DataTypeUriFolder DataType = "uri_folder" +) + +func PossibleValuesForDataType() []string { + return []string{ + string(DataTypeMltable), + string(DataTypeUriFile), + string(DataTypeUriFolder), + } +} + +func (s *DataType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataType(input string) (*DataType, error) { + vals := map[string]DataType{ + "mltable": DataTypeMltable, + "uri_file": DataTypeUriFile, + "uri_folder": DataTypeUriFolder, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataType(input) + return &out, nil +} + +type ListViewType string + +const ( + ListViewTypeActiveOnly ListViewType = "ActiveOnly" + ListViewTypeAll ListViewType = "All" + ListViewTypeArchivedOnly ListViewType = "ArchivedOnly" +) + +func PossibleValuesForListViewType() []string { + return []string{ + string(ListViewTypeActiveOnly), + string(ListViewTypeAll), + string(ListViewTypeArchivedOnly), + } +} + +func (s *ListViewType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseListViewType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseListViewType(input string) (*ListViewType, error) { + vals := map[string]ListViewType{ + "activeonly": ListViewTypeActiveOnly, + "all": ListViewTypeAll, + "archivedonly": ListViewTypeArchivedOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ListViewType(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversion/id_dataversion.go b/resource-manager/machinelearningservices/2025-04-01/dataversion/id_dataversion.go new file mode 100644 index 00000000000..e9c96cb9cc2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversion/id_dataversion.go @@ -0,0 +1,148 @@ +package dataversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DataVersionId{}) +} + +var _ resourceids.ResourceId = &DataVersionId{} + +// DataVersionId is a struct representing the Resource ID for a Data Version +type DataVersionId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + DataName string + VersionName string +} + +// NewDataVersionID returns a new DataVersionId struct +func NewDataVersionID(subscriptionId string, resourceGroupName string, workspaceName string, dataName string, versionName string) DataVersionId { + return DataVersionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + DataName: dataName, + VersionName: versionName, + } +} + +// ParseDataVersionID parses 'input' into a DataVersionId +func ParseDataVersionID(input string) (*DataVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDataVersionIDInsensitively parses 'input' case-insensitively into a DataVersionId +// note: this method should only be used for API response data and not user input +func ParseDataVersionIDInsensitively(input string) (*DataVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DataVersionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.DataName, ok = input.Parsed["dataName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dataName", input) + } + + if id.VersionName, ok = input.Parsed["versionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "versionName", input) + } + + return nil +} + +// ValidateDataVersionID checks that 'input' can be parsed as a Data Version ID +func ValidateDataVersionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseDataVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Data Version ID +func (id DataVersionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/data/%s/versions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.DataName, id.VersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Data Version ID +func (id DataVersionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticData", "data", "data"), + resourceids.UserSpecifiedSegment("dataName", "dataName"), + resourceids.StaticSegment("staticVersions", "versions", "versions"), + resourceids.UserSpecifiedSegment("versionName", "versionName"), + } +} + +// String returns a human-readable description of this Data Version ID +func (id DataVersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Data Name: %q", id.DataName), + fmt.Sprintf("Version Name: %q", id.VersionName), + } + return fmt.Sprintf("Data Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversion/id_dataversion_test.go b/resource-manager/machinelearningservices/2025-04-01/dataversion/id_dataversion_test.go new file mode 100644 index 00000000000..50f9cfa71a9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversion/id_dataversion_test.go @@ -0,0 +1,372 @@ +package dataversion + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DataVersionId{} + +func TestNewDataVersionID(t *testing.T) { + id := NewDataVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataName", "versionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.DataName != "dataName" { + t.Fatalf("Expected %q but got %q for Segment 'DataName'", id.DataName, "dataName") + } + + if id.VersionName != "versionName" { + t.Fatalf("Expected %q but got %q for Segment 'VersionName'", id.VersionName, "versionName") + } +} + +func TestFormatDataVersionID(t *testing.T) { + actual := NewDataVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataName", "versionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/data/dataName/versions/versionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDataVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/data", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/data/dataName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/data/dataName/versions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/data/dataName/versions/versionName", + Expected: &DataVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + DataName: "dataName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/data/dataName/versions/versionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.DataName != v.Expected.DataName { + t.Fatalf("Expected %q but got %q for DataName", v.Expected.DataName, actual.DataName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestParseDataVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/data", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/dAtA", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/data/dataName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/dAtA/dAtAnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/data/dataName/versions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/dAtA/dAtAnAmE/vErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/data/dataName/versions/versionName", + Expected: &DataVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + DataName: "dataName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/data/dataName/versions/versionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/dAtA/dAtAnAmE/vErSiOnS/vErSiOnNaMe", + Expected: &DataVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + DataName: "dAtAnAmE", + VersionName: "vErSiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/dAtA/dAtAnAmE/vErSiOnS/vErSiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.DataName != v.Expected.DataName { + t.Fatalf("Expected %q but got %q for DataName", v.Expected.DataName, actual.DataName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestSegmentsForDataVersionId(t *testing.T) { + segments := DataVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DataVersionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversion/id_workspacedata.go b/resource-manager/machinelearningservices/2025-04-01/dataversion/id_workspacedata.go new file mode 100644 index 00000000000..dcc5a656eea --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversion/id_workspacedata.go @@ -0,0 +1,139 @@ +package dataversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceDataId{}) +} + +var _ resourceids.ResourceId = &WorkspaceDataId{} + +// WorkspaceDataId is a struct representing the Resource ID for a Workspace Data +type WorkspaceDataId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + DataName string +} + +// NewWorkspaceDataID returns a new WorkspaceDataId struct +func NewWorkspaceDataID(subscriptionId string, resourceGroupName string, workspaceName string, dataName string) WorkspaceDataId { + return WorkspaceDataId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + DataName: dataName, + } +} + +// ParseWorkspaceDataID parses 'input' into a WorkspaceDataId +func ParseWorkspaceDataID(input string) (*WorkspaceDataId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceDataId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceDataId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceDataIDInsensitively parses 'input' case-insensitively into a WorkspaceDataId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceDataIDInsensitively(input string) (*WorkspaceDataId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceDataId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceDataId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceDataId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.DataName, ok = input.Parsed["dataName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dataName", input) + } + + return nil +} + +// ValidateWorkspaceDataID checks that 'input' can be parsed as a Workspace Data ID +func ValidateWorkspaceDataID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceDataID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace Data ID +func (id WorkspaceDataId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/data/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.DataName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace Data ID +func (id WorkspaceDataId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticData", "data", "data"), + resourceids.UserSpecifiedSegment("dataName", "dataName"), + } +} + +// String returns a human-readable description of this Workspace Data ID +func (id WorkspaceDataId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Data Name: %q", id.DataName), + } + return fmt.Sprintf("Workspace Data (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversion/id_workspacedata_test.go b/resource-manager/machinelearningservices/2025-04-01/dataversion/id_workspacedata_test.go new file mode 100644 index 00000000000..11cccd4e6f6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversion/id_workspacedata_test.go @@ -0,0 +1,327 @@ +package dataversion + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceDataId{} + +func TestNewWorkspaceDataID(t *testing.T) { + id := NewWorkspaceDataID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.DataName != "dataName" { + t.Fatalf("Expected %q but got %q for Segment 'DataName'", id.DataName, "dataName") + } +} + +func TestFormatWorkspaceDataID(t *testing.T) { + actual := NewWorkspaceDataID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "dataName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/data/dataName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceDataID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceDataId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/data", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/data/dataName", + Expected: &WorkspaceDataId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + DataName: "dataName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/data/dataName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceDataID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.DataName != v.Expected.DataName { + t.Fatalf("Expected %q but got %q for DataName", v.Expected.DataName, actual.DataName) + } + + } +} + +func TestParseWorkspaceDataIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceDataId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/data", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/dAtA", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/data/dataName", + Expected: &WorkspaceDataId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + DataName: "dataName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/data/dataName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/dAtA/dAtAnAmE", + Expected: &WorkspaceDataId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + DataName: "dAtAnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/dAtA/dAtAnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceDataIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.DataName != v.Expected.DataName { + t.Fatalf("Expected %q but got %q for DataName", v.Expected.DataName, actual.DataName) + } + + } +} + +func TestSegmentsForWorkspaceDataId(t *testing.T) { + segments := WorkspaceDataId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceDataId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversion/method_createorupdate.go b/resource-manager/machinelearningservices/2025-04-01/dataversion/method_createorupdate.go new file mode 100644 index 00000000000..8cf62264d10 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversion/method_createorupdate.go @@ -0,0 +1,58 @@ +package dataversion + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *DataVersionBaseResource +} + +// CreateOrUpdate ... +func (c DataVersionClient) CreateOrUpdate(ctx context.Context, id DataVersionId, input DataVersionBaseResource) (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 DataVersionBaseResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversion/method_delete.go b/resource-manager/machinelearningservices/2025-04-01/dataversion/method_delete.go new file mode 100644 index 00000000000..3f72dee6a2c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversion/method_delete.go @@ -0,0 +1,47 @@ +package dataversion + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 DataVersionClient) Delete(ctx context.Context, id DataVersionId) (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/machinelearningservices/2025-04-01/dataversion/method_get.go b/resource-manager/machinelearningservices/2025-04-01/dataversion/method_get.go new file mode 100644 index 00000000000..696acdfeeb4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversion/method_get.go @@ -0,0 +1,53 @@ +package dataversion + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *DataVersionBaseResource +} + +// Get ... +func (c DataVersionClient) Get(ctx context.Context, id DataVersionId) (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 DataVersionBaseResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversion/method_list.go b/resource-manager/machinelearningservices/2025-04-01/dataversion/method_list.go new file mode 100644 index 00000000000..1533244b108 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversion/method_list.go @@ -0,0 +1,150 @@ +package dataversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]DataVersionBaseResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []DataVersionBaseResource +} + +type ListOperationOptions struct { + ListViewType *ListViewType + OrderBy *string + Skip *string + Tags *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ListViewType != nil { + out.Append("listViewType", fmt.Sprintf("%v", *o.ListViewType)) + } + if o.OrderBy != nil { + out.Append("$orderBy", fmt.Sprintf("%v", *o.OrderBy)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Tags != nil { + out.Append("$tags", fmt.Sprintf("%v", *o.Tags)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c DataVersionClient) List(ctx context.Context, id WorkspaceDataId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/versions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DataVersionBaseResource `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 DataVersionClient) ListComplete(ctx context.Context, id WorkspaceDataId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, DataVersionBaseResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DataVersionClient) ListCompleteMatchingPredicate(ctx context.Context, id WorkspaceDataId, options ListOperationOptions, predicate DataVersionBaseResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]DataVersionBaseResource, 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/machinelearningservices/2025-04-01/dataversion/method_publish.go b/resource-manager/machinelearningservices/2025-04-01/dataversion/method_publish.go new file mode 100644 index 00000000000..862ddbde5fe --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversion/method_publish.go @@ -0,0 +1,74 @@ +package dataversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublishOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Publish ... +func (c DataVersionClient) Publish(ctx context.Context, id DataVersionId, input DestinationAsset) (result PublishOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/publish", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// PublishThenPoll performs Publish then polls until it's completed +func (c DataVersionClient) PublishThenPoll(ctx context.Context, id DataVersionId, input DestinationAsset) error { + result, err := c.Publish(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Publish: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Publish: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversion/model_dataversionbase.go b/resource-manager/machinelearningservices/2025-04-01/dataversion/model_dataversionbase.go new file mode 100644 index 00000000000..f3993e465f3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversion/model_dataversionbase.go @@ -0,0 +1,97 @@ +package dataversion + +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 DataVersionBase interface { + DataVersionBase() BaseDataVersionBaseImpl +} + +var _ DataVersionBase = BaseDataVersionBaseImpl{} + +type BaseDataVersionBaseImpl struct { + DataType DataType `json:"dataType"` + DataUri string `json:"dataUri"` + Description *string `json:"description,omitempty"` + IsAnonymous *bool `json:"isAnonymous,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +func (s BaseDataVersionBaseImpl) DataVersionBase() BaseDataVersionBaseImpl { + return s +} + +var _ DataVersionBase = RawDataVersionBaseImpl{} + +// RawDataVersionBaseImpl 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 RawDataVersionBaseImpl struct { + dataVersionBase BaseDataVersionBaseImpl + Type string + Values map[string]interface{} +} + +func (s RawDataVersionBaseImpl) DataVersionBase() BaseDataVersionBaseImpl { + return s.dataVersionBase +} + +func UnmarshalDataVersionBaseImplementation(input []byte) (DataVersionBase, 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 DataVersionBase into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["dataType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "mltable") { + var out MLTableData + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MLTableData: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "uri_file") { + var out UriFileDataVersion + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into UriFileDataVersion: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "uri_folder") { + var out UriFolderDataVersion + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into UriFolderDataVersion: %+v", err) + } + return out, nil + } + + var parent BaseDataVersionBaseImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseDataVersionBaseImpl: %+v", err) + } + + return RawDataVersionBaseImpl{ + dataVersionBase: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversion/model_dataversionbaseresource.go b/resource-manager/machinelearningservices/2025-04-01/dataversion/model_dataversionbaseresource.go new file mode 100644 index 00000000000..27e70e9a245 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversion/model_dataversionbaseresource.go @@ -0,0 +1,53 @@ +package dataversion + +import ( + "encoding/json" + "fmt" + + "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 DataVersionBaseResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties DataVersionBase `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &DataVersionBaseResource{} + +func (s *DataVersionBaseResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Id = decoded.Id + s.Name = decoded.Name + s.SystemData = decoded.SystemData + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling DataVersionBaseResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalDataVersionBaseImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'DataVersionBaseResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversion/model_destinationasset.go b/resource-manager/machinelearningservices/2025-04-01/dataversion/model_destinationasset.go new file mode 100644 index 00000000000..e77607557b8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversion/model_destinationasset.go @@ -0,0 +1,10 @@ +package dataversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DestinationAsset struct { + DestinationName *string `json:"destinationName,omitempty"` + DestinationVersion *string `json:"destinationVersion,omitempty"` + RegistryName *string `json:"registryName,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversion/model_mltabledata.go b/resource-manager/machinelearningservices/2025-04-01/dataversion/model_mltabledata.go new file mode 100644 index 00000000000..0e5c16ecd56 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversion/model_mltabledata.go @@ -0,0 +1,62 @@ +package dataversion + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DataVersionBase = MLTableData{} + +type MLTableData struct { + ReferencedUris *[]string `json:"referencedUris,omitempty"` + + // Fields inherited from DataVersionBase + + DataType DataType `json:"dataType"` + DataUri string `json:"dataUri"` + Description *string `json:"description,omitempty"` + IsAnonymous *bool `json:"isAnonymous,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +func (s MLTableData) DataVersionBase() BaseDataVersionBaseImpl { + return BaseDataVersionBaseImpl{ + DataType: s.DataType, + DataUri: s.DataUri, + Description: s.Description, + IsAnonymous: s.IsAnonymous, + IsArchived: s.IsArchived, + Properties: s.Properties, + Tags: s.Tags, + } +} + +var _ json.Marshaler = MLTableData{} + +func (s MLTableData) MarshalJSON() ([]byte, error) { + type wrapper MLTableData + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MLTableData: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MLTableData: %+v", err) + } + + decoded["dataType"] = "mltable" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MLTableData: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversion/model_urifiledataversion.go b/resource-manager/machinelearningservices/2025-04-01/dataversion/model_urifiledataversion.go new file mode 100644 index 00000000000..d409ed0dfa5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversion/model_urifiledataversion.go @@ -0,0 +1,61 @@ +package dataversion + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DataVersionBase = UriFileDataVersion{} + +type UriFileDataVersion struct { + + // Fields inherited from DataVersionBase + + DataType DataType `json:"dataType"` + DataUri string `json:"dataUri"` + Description *string `json:"description,omitempty"` + IsAnonymous *bool `json:"isAnonymous,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +func (s UriFileDataVersion) DataVersionBase() BaseDataVersionBaseImpl { + return BaseDataVersionBaseImpl{ + DataType: s.DataType, + DataUri: s.DataUri, + Description: s.Description, + IsAnonymous: s.IsAnonymous, + IsArchived: s.IsArchived, + Properties: s.Properties, + Tags: s.Tags, + } +} + +var _ json.Marshaler = UriFileDataVersion{} + +func (s UriFileDataVersion) MarshalJSON() ([]byte, error) { + type wrapper UriFileDataVersion + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling UriFileDataVersion: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling UriFileDataVersion: %+v", err) + } + + decoded["dataType"] = "uri_file" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling UriFileDataVersion: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversion/model_urifolderdataversion.go b/resource-manager/machinelearningservices/2025-04-01/dataversion/model_urifolderdataversion.go new file mode 100644 index 00000000000..60dd9f4d067 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversion/model_urifolderdataversion.go @@ -0,0 +1,61 @@ +package dataversion + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DataVersionBase = UriFolderDataVersion{} + +type UriFolderDataVersion struct { + + // Fields inherited from DataVersionBase + + DataType DataType `json:"dataType"` + DataUri string `json:"dataUri"` + Description *string `json:"description,omitempty"` + IsAnonymous *bool `json:"isAnonymous,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +func (s UriFolderDataVersion) DataVersionBase() BaseDataVersionBaseImpl { + return BaseDataVersionBaseImpl{ + DataType: s.DataType, + DataUri: s.DataUri, + Description: s.Description, + IsAnonymous: s.IsAnonymous, + IsArchived: s.IsArchived, + Properties: s.Properties, + Tags: s.Tags, + } +} + +var _ json.Marshaler = UriFolderDataVersion{} + +func (s UriFolderDataVersion) MarshalJSON() ([]byte, error) { + type wrapper UriFolderDataVersion + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling UriFolderDataVersion: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling UriFolderDataVersion: %+v", err) + } + + decoded["dataType"] = "uri_folder" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling UriFolderDataVersion: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversion/predicates.go b/resource-manager/machinelearningservices/2025-04-01/dataversion/predicates.go new file mode 100644 index 00000000000..29cdd8a9a0e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversion/predicates.go @@ -0,0 +1,27 @@ +package dataversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataVersionBaseResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p DataVersionBaseResourceOperationPredicate) Matches(input DataVersionBaseResource) 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/machinelearningservices/2025-04-01/dataversion/version.go b/resource-manager/machinelearningservices/2025-04-01/dataversion/version.go new file mode 100644 index 00000000000..8399cd17d2b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversion/version.go @@ -0,0 +1,10 @@ +package dataversion + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/dataversion/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/README.md b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/README.md new file mode 100644 index 00000000000..f75c92ec5d7 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/README.md @@ -0,0 +1,103 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/dataversionregistry` Documentation + +The `dataversionregistry` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/dataversionregistry" +``` + + +### Client Initialization + +```go +client := dataversionregistry.NewDataVersionRegistryClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `DataVersionRegistryClient.RegistryDataVersionsCreateOrGetStartPendingUpload` + +```go +ctx := context.TODO() +id := dataversionregistry.NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "dataName", "versionName") + +payload := dataversionregistry.PendingUploadRequestDto{ + // ... +} + + +read, err := client.RegistryDataVersionsCreateOrGetStartPendingUpload(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DataVersionRegistryClient.RegistryDataVersionsCreateOrUpdate` + +```go +ctx := context.TODO() +id := dataversionregistry.NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "dataName", "versionName") + +payload := dataversionregistry.DataVersionBaseResource{ + // ... +} + + +if err := client.RegistryDataVersionsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `DataVersionRegistryClient.RegistryDataVersionsDelete` + +```go +ctx := context.TODO() +id := dataversionregistry.NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "dataName", "versionName") + +if err := client.RegistryDataVersionsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `DataVersionRegistryClient.RegistryDataVersionsGet` + +```go +ctx := context.TODO() +id := dataversionregistry.NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "dataName", "versionName") + +read, err := client.RegistryDataVersionsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `DataVersionRegistryClient.RegistryDataVersionsList` + +```go +ctx := context.TODO() +id := dataversionregistry.NewDataID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "dataName") + +// alternatively `client.RegistryDataVersionsList(ctx, id, dataversionregistry.DefaultRegistryDataVersionsListOperationOptions())` can be used to do batched pagination +items, err := client.RegistryDataVersionsListComplete(ctx, id, dataversionregistry.DefaultRegistryDataVersionsListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/client.go b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/client.go new file mode 100644 index 00000000000..b4352712d79 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/client.go @@ -0,0 +1,26 @@ +package dataversionregistry + +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 DataVersionRegistryClient struct { + Client *resourcemanager.Client +} + +func NewDataVersionRegistryClientWithBaseURI(sdkApi sdkEnv.Api) (*DataVersionRegistryClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "dataversionregistry", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating DataVersionRegistryClient: %+v", err) + } + + return &DataVersionRegistryClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/constants.go b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/constants.go new file mode 100644 index 00000000000..2a57cfd73cc --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/constants.go @@ -0,0 +1,177 @@ +package dataversionregistry + +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 DataType string + +const ( + DataTypeMltable DataType = "mltable" + DataTypeUriFile DataType = "uri_file" + DataTypeUriFolder DataType = "uri_folder" +) + +func PossibleValuesForDataType() []string { + return []string{ + string(DataTypeMltable), + string(DataTypeUriFile), + string(DataTypeUriFolder), + } +} + +func (s *DataType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataType(input string) (*DataType, error) { + vals := map[string]DataType{ + "mltable": DataTypeMltable, + "uri_file": DataTypeUriFile, + "uri_folder": DataTypeUriFolder, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataType(input) + return &out, nil +} + +type ListViewType string + +const ( + ListViewTypeActiveOnly ListViewType = "ActiveOnly" + ListViewTypeAll ListViewType = "All" + ListViewTypeArchivedOnly ListViewType = "ArchivedOnly" +) + +func PossibleValuesForListViewType() []string { + return []string{ + string(ListViewTypeActiveOnly), + string(ListViewTypeAll), + string(ListViewTypeArchivedOnly), + } +} + +func (s *ListViewType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseListViewType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseListViewType(input string) (*ListViewType, error) { + vals := map[string]ListViewType{ + "activeonly": ListViewTypeActiveOnly, + "all": ListViewTypeAll, + "archivedonly": ListViewTypeArchivedOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ListViewType(input) + return &out, nil +} + +type PendingUploadCredentialType string + +const ( + PendingUploadCredentialTypeSAS PendingUploadCredentialType = "SAS" +) + +func PossibleValuesForPendingUploadCredentialType() []string { + return []string{ + string(PendingUploadCredentialTypeSAS), + } +} + +func (s *PendingUploadCredentialType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePendingUploadCredentialType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePendingUploadCredentialType(input string) (*PendingUploadCredentialType, error) { + vals := map[string]PendingUploadCredentialType{ + "sas": PendingUploadCredentialTypeSAS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PendingUploadCredentialType(input) + return &out, nil +} + +type PendingUploadType string + +const ( + PendingUploadTypeNone PendingUploadType = "None" + PendingUploadTypeTemporaryBlobReference PendingUploadType = "TemporaryBlobReference" +) + +func PossibleValuesForPendingUploadType() []string { + return []string{ + string(PendingUploadTypeNone), + string(PendingUploadTypeTemporaryBlobReference), + } +} + +func (s *PendingUploadType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePendingUploadType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePendingUploadType(input string) (*PendingUploadType, error) { + vals := map[string]PendingUploadType{ + "none": PendingUploadTypeNone, + "temporaryblobreference": PendingUploadTypeTemporaryBlobReference, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PendingUploadType(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/id_data.go b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/id_data.go new file mode 100644 index 00000000000..5d54702dfe2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/id_data.go @@ -0,0 +1,139 @@ +package dataversionregistry + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&DataId{}) +} + +var _ resourceids.ResourceId = &DataId{} + +// DataId is a struct representing the Resource ID for a Data +type DataId struct { + SubscriptionId string + ResourceGroupName string + RegistryName string + DataName string +} + +// NewDataID returns a new DataId struct +func NewDataID(subscriptionId string, resourceGroupName string, registryName string, dataName string) DataId { + return DataId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RegistryName: registryName, + DataName: dataName, + } +} + +// ParseDataID parses 'input' into a DataId +func ParseDataID(input string) (*DataId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseDataIDInsensitively parses 'input' case-insensitively into a DataId +// note: this method should only be used for API response data and not user input +func ParseDataIDInsensitively(input string) (*DataId, error) { + parser := resourceids.NewParserFromResourceIdType(&DataId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := DataId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *DataId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RegistryName, ok = input.Parsed["registryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "registryName", input) + } + + if id.DataName, ok = input.Parsed["dataName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dataName", input) + } + + return nil +} + +// ValidateDataID checks that 'input' can be parsed as a Data ID +func ValidateDataID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseDataID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Data ID +func (id DataId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/registries/%s/data/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RegistryName, id.DataName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Data ID +func (id DataId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticRegistries", "registries", "registries"), + resourceids.UserSpecifiedSegment("registryName", "registryName"), + resourceids.StaticSegment("staticData", "data", "data"), + resourceids.UserSpecifiedSegment("dataName", "dataName"), + } +} + +// String returns a human-readable description of this Data ID +func (id DataId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Registry Name: %q", id.RegistryName), + fmt.Sprintf("Data Name: %q", id.DataName), + } + return fmt.Sprintf("Data (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/id_data_test.go b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/id_data_test.go new file mode 100644 index 00000000000..4dfc01596eb --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/id_data_test.go @@ -0,0 +1,327 @@ +package dataversionregistry + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &DataId{} + +func TestNewDataID(t *testing.T) { + id := NewDataID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "dataName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RegistryName != "registryName" { + t.Fatalf("Expected %q but got %q for Segment 'RegistryName'", id.RegistryName, "registryName") + } + + if id.DataName != "dataName" { + t.Fatalf("Expected %q but got %q for Segment 'DataName'", id.DataName, "dataName") + } +} + +func TestFormatDataID(t *testing.T) { + actual := NewDataID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "dataName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/data/dataName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseDataID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/data", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/data/dataName", + Expected: &DataId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + DataName: "dataName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/data/dataName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.DataName != v.Expected.DataName { + t.Fatalf("Expected %q but got %q for DataName", v.Expected.DataName, actual.DataName) + } + + } +} + +func TestParseDataIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *DataId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/data", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/dAtA", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/data/dataName", + Expected: &DataId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + DataName: "dataName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/data/dataName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/dAtA/dAtAnAmE", + Expected: &DataId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RegistryName: "rEgIsTrYnAmE", + DataName: "dAtAnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/dAtA/dAtAnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseDataIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.DataName != v.Expected.DataName { + t.Fatalf("Expected %q but got %q for DataName", v.Expected.DataName, actual.DataName) + } + + } +} + +func TestSegmentsForDataId(t *testing.T) { + segments := DataId{}.Segments() + if len(segments) == 0 { + t.Fatalf("DataId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/id_version.go b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/id_version.go new file mode 100644 index 00000000000..ca59eb9aee0 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/id_version.go @@ -0,0 +1,148 @@ +package dataversionregistry + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&VersionId{}) +} + +var _ resourceids.ResourceId = &VersionId{} + +// VersionId is a struct representing the Resource ID for a Version +type VersionId struct { + SubscriptionId string + ResourceGroupName string + RegistryName string + DataName string + VersionName string +} + +// NewVersionID returns a new VersionId struct +func NewVersionID(subscriptionId string, resourceGroupName string, registryName string, dataName string, versionName string) VersionId { + return VersionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RegistryName: registryName, + DataName: dataName, + VersionName: versionName, + } +} + +// ParseVersionID parses 'input' into a VersionId +func ParseVersionID(input string) (*VersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&VersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseVersionIDInsensitively parses 'input' case-insensitively into a VersionId +// note: this method should only be used for API response data and not user input +func ParseVersionIDInsensitively(input string) (*VersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&VersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := VersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *VersionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RegistryName, ok = input.Parsed["registryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "registryName", input) + } + + if id.DataName, ok = input.Parsed["dataName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "dataName", input) + } + + if id.VersionName, ok = input.Parsed["versionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "versionName", input) + } + + return nil +} + +// ValidateVersionID checks that 'input' can be parsed as a Version ID +func ValidateVersionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Version ID +func (id VersionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/registries/%s/data/%s/versions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RegistryName, id.DataName, id.VersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Version ID +func (id VersionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticRegistries", "registries", "registries"), + resourceids.UserSpecifiedSegment("registryName", "registryName"), + resourceids.StaticSegment("staticData", "data", "data"), + resourceids.UserSpecifiedSegment("dataName", "dataName"), + resourceids.StaticSegment("staticVersions", "versions", "versions"), + resourceids.UserSpecifiedSegment("versionName", "versionName"), + } +} + +// String returns a human-readable description of this Version ID +func (id VersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Registry Name: %q", id.RegistryName), + fmt.Sprintf("Data Name: %q", id.DataName), + fmt.Sprintf("Version Name: %q", id.VersionName), + } + return fmt.Sprintf("Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/id_version_test.go b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/id_version_test.go new file mode 100644 index 00000000000..53d1845af90 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/id_version_test.go @@ -0,0 +1,372 @@ +package dataversionregistry + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &VersionId{} + +func TestNewVersionID(t *testing.T) { + id := NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "dataName", "versionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RegistryName != "registryName" { + t.Fatalf("Expected %q but got %q for Segment 'RegistryName'", id.RegistryName, "registryName") + } + + if id.DataName != "dataName" { + t.Fatalf("Expected %q but got %q for Segment 'DataName'", id.DataName, "dataName") + } + + if id.VersionName != "versionName" { + t.Fatalf("Expected %q but got %q for Segment 'VersionName'", id.VersionName, "versionName") + } +} + +func TestFormatVersionID(t *testing.T) { + actual := NewVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "dataName", "versionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/data/dataName/versions/versionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/data", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/data/dataName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/data/dataName/versions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/data/dataName/versions/versionName", + Expected: &VersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + DataName: "dataName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/data/dataName/versions/versionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.DataName != v.Expected.DataName { + t.Fatalf("Expected %q but got %q for DataName", v.Expected.DataName, actual.DataName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestParseVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *VersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/data", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/dAtA", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/data/dataName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/dAtA/dAtAnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/data/dataName/versions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/dAtA/dAtAnAmE/vErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/data/dataName/versions/versionName", + Expected: &VersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + DataName: "dataName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/data/dataName/versions/versionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/dAtA/dAtAnAmE/vErSiOnS/vErSiOnNaMe", + Expected: &VersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RegistryName: "rEgIsTrYnAmE", + DataName: "dAtAnAmE", + VersionName: "vErSiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/dAtA/dAtAnAmE/vErSiOnS/vErSiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.DataName != v.Expected.DataName { + t.Fatalf("Expected %q but got %q for DataName", v.Expected.DataName, actual.DataName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestSegmentsForVersionId(t *testing.T) { + segments := VersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("VersionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/method_registrydataversionscreateorgetstartpendingupload.go b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/method_registrydataversionscreateorgetstartpendingupload.go new file mode 100644 index 00000000000..3bf75f7684d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/method_registrydataversionscreateorgetstartpendingupload.go @@ -0,0 +1,58 @@ +package dataversionregistry + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryDataVersionsCreateOrGetStartPendingUploadOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PendingUploadResponseDto +} + +// RegistryDataVersionsCreateOrGetStartPendingUpload ... +func (c DataVersionRegistryClient) RegistryDataVersionsCreateOrGetStartPendingUpload(ctx context.Context, id VersionId, input PendingUploadRequestDto) (result RegistryDataVersionsCreateOrGetStartPendingUploadOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/startPendingUpload", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PendingUploadResponseDto + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/method_registrydataversionscreateorupdate.go b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/method_registrydataversionscreateorupdate.go new file mode 100644 index 00000000000..df82bc20061 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/method_registrydataversionscreateorupdate.go @@ -0,0 +1,75 @@ +package dataversionregistry + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryDataVersionsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DataVersionBaseResource +} + +// RegistryDataVersionsCreateOrUpdate ... +func (c DataVersionRegistryClient) RegistryDataVersionsCreateOrUpdate(ctx context.Context, id VersionId, input DataVersionBaseResource) (result RegistryDataVersionsCreateOrUpdateOperationResponse, 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 +} + +// RegistryDataVersionsCreateOrUpdateThenPoll performs RegistryDataVersionsCreateOrUpdate then polls until it's completed +func (c DataVersionRegistryClient) RegistryDataVersionsCreateOrUpdateThenPoll(ctx context.Context, id VersionId, input DataVersionBaseResource) error { + result, err := c.RegistryDataVersionsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RegistryDataVersionsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegistryDataVersionsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/method_registrydataversionsdelete.go b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/method_registrydataversionsdelete.go new file mode 100644 index 00000000000..b4eebd00065 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/method_registrydataversionsdelete.go @@ -0,0 +1,71 @@ +package dataversionregistry + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryDataVersionsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RegistryDataVersionsDelete ... +func (c DataVersionRegistryClient) RegistryDataVersionsDelete(ctx context.Context, id VersionId) (result RegistryDataVersionsDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RegistryDataVersionsDeleteThenPoll performs RegistryDataVersionsDelete then polls until it's completed +func (c DataVersionRegistryClient) RegistryDataVersionsDeleteThenPoll(ctx context.Context, id VersionId) error { + result, err := c.RegistryDataVersionsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing RegistryDataVersionsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegistryDataVersionsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/method_registrydataversionsget.go b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/method_registrydataversionsget.go new file mode 100644 index 00000000000..3ab0a0c3513 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/method_registrydataversionsget.go @@ -0,0 +1,53 @@ +package dataversionregistry + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryDataVersionsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DataVersionBaseResource +} + +// RegistryDataVersionsGet ... +func (c DataVersionRegistryClient) RegistryDataVersionsGet(ctx context.Context, id VersionId) (result RegistryDataVersionsGetOperationResponse, 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 DataVersionBaseResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/method_registrydataversionslist.go b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/method_registrydataversionslist.go new file mode 100644 index 00000000000..e49f7321eb1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/method_registrydataversionslist.go @@ -0,0 +1,150 @@ +package dataversionregistry + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryDataVersionsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]DataVersionBaseResource +} + +type RegistryDataVersionsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []DataVersionBaseResource +} + +type RegistryDataVersionsListOperationOptions struct { + ListViewType *ListViewType + OrderBy *string + Skip *string + Tags *string + Top *int64 +} + +func DefaultRegistryDataVersionsListOperationOptions() RegistryDataVersionsListOperationOptions { + return RegistryDataVersionsListOperationOptions{} +} + +func (o RegistryDataVersionsListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RegistryDataVersionsListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RegistryDataVersionsListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ListViewType != nil { + out.Append("listViewType", fmt.Sprintf("%v", *o.ListViewType)) + } + if o.OrderBy != nil { + out.Append("$orderBy", fmt.Sprintf("%v", *o.OrderBy)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Tags != nil { + out.Append("$tags", fmt.Sprintf("%v", *o.Tags)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type RegistryDataVersionsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *RegistryDataVersionsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// RegistryDataVersionsList ... +func (c DataVersionRegistryClient) RegistryDataVersionsList(ctx context.Context, id DataId, options RegistryDataVersionsListOperationOptions) (result RegistryDataVersionsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &RegistryDataVersionsListCustomPager{}, + Path: fmt.Sprintf("%s/versions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]DataVersionBaseResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RegistryDataVersionsListComplete retrieves all the results into a single object +func (c DataVersionRegistryClient) RegistryDataVersionsListComplete(ctx context.Context, id DataId, options RegistryDataVersionsListOperationOptions) (RegistryDataVersionsListCompleteResult, error) { + return c.RegistryDataVersionsListCompleteMatchingPredicate(ctx, id, options, DataVersionBaseResourceOperationPredicate{}) +} + +// RegistryDataVersionsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c DataVersionRegistryClient) RegistryDataVersionsListCompleteMatchingPredicate(ctx context.Context, id DataId, options RegistryDataVersionsListOperationOptions, predicate DataVersionBaseResourceOperationPredicate) (result RegistryDataVersionsListCompleteResult, err error) { + items := make([]DataVersionBaseResource, 0) + + resp, err := c.RegistryDataVersionsList(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 = RegistryDataVersionsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_blobreferenceforconsumptiondto.go b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_blobreferenceforconsumptiondto.go new file mode 100644 index 00000000000..ab7f8d5e7d7 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_blobreferenceforconsumptiondto.go @@ -0,0 +1,45 @@ +package dataversionregistry + +import ( + "encoding/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 BlobReferenceForConsumptionDto struct { + BlobUri *string `json:"blobUri,omitempty"` + Credential PendingUploadCredentialDto `json:"credential"` + StorageAccountArmId *string `json:"storageAccountArmId,omitempty"` +} + +var _ json.Unmarshaler = &BlobReferenceForConsumptionDto{} + +func (s *BlobReferenceForConsumptionDto) UnmarshalJSON(bytes []byte) error { + var decoded struct { + BlobUri *string `json:"blobUri,omitempty"` + StorageAccountArmId *string `json:"storageAccountArmId,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.BlobUri = decoded.BlobUri + s.StorageAccountArmId = decoded.StorageAccountArmId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling BlobReferenceForConsumptionDto into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["credential"]; ok { + impl, err := UnmarshalPendingUploadCredentialDtoImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Credential' for 'BlobReferenceForConsumptionDto': %+v", err) + } + s.Credential = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_dataversionbase.go b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_dataversionbase.go new file mode 100644 index 00000000000..cbfadd70222 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_dataversionbase.go @@ -0,0 +1,97 @@ +package dataversionregistry + +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 DataVersionBase interface { + DataVersionBase() BaseDataVersionBaseImpl +} + +var _ DataVersionBase = BaseDataVersionBaseImpl{} + +type BaseDataVersionBaseImpl struct { + DataType DataType `json:"dataType"` + DataUri string `json:"dataUri"` + Description *string `json:"description,omitempty"` + IsAnonymous *bool `json:"isAnonymous,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +func (s BaseDataVersionBaseImpl) DataVersionBase() BaseDataVersionBaseImpl { + return s +} + +var _ DataVersionBase = RawDataVersionBaseImpl{} + +// RawDataVersionBaseImpl 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 RawDataVersionBaseImpl struct { + dataVersionBase BaseDataVersionBaseImpl + Type string + Values map[string]interface{} +} + +func (s RawDataVersionBaseImpl) DataVersionBase() BaseDataVersionBaseImpl { + return s.dataVersionBase +} + +func UnmarshalDataVersionBaseImplementation(input []byte) (DataVersionBase, 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 DataVersionBase into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["dataType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "mltable") { + var out MLTableData + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MLTableData: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "uri_file") { + var out UriFileDataVersion + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into UriFileDataVersion: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "uri_folder") { + var out UriFolderDataVersion + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into UriFolderDataVersion: %+v", err) + } + return out, nil + } + + var parent BaseDataVersionBaseImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseDataVersionBaseImpl: %+v", err) + } + + return RawDataVersionBaseImpl{ + dataVersionBase: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_dataversionbaseresource.go b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_dataversionbaseresource.go new file mode 100644 index 00000000000..f4a295fb9f3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_dataversionbaseresource.go @@ -0,0 +1,53 @@ +package dataversionregistry + +import ( + "encoding/json" + "fmt" + + "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 DataVersionBaseResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties DataVersionBase `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &DataVersionBaseResource{} + +func (s *DataVersionBaseResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Id = decoded.Id + s.Name = decoded.Name + s.SystemData = decoded.SystemData + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling DataVersionBaseResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalDataVersionBaseImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'DataVersionBaseResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_mltabledata.go b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_mltabledata.go new file mode 100644 index 00000000000..7bb306b22da --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_mltabledata.go @@ -0,0 +1,62 @@ +package dataversionregistry + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DataVersionBase = MLTableData{} + +type MLTableData struct { + ReferencedUris *[]string `json:"referencedUris,omitempty"` + + // Fields inherited from DataVersionBase + + DataType DataType `json:"dataType"` + DataUri string `json:"dataUri"` + Description *string `json:"description,omitempty"` + IsAnonymous *bool `json:"isAnonymous,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +func (s MLTableData) DataVersionBase() BaseDataVersionBaseImpl { + return BaseDataVersionBaseImpl{ + DataType: s.DataType, + DataUri: s.DataUri, + Description: s.Description, + IsAnonymous: s.IsAnonymous, + IsArchived: s.IsArchived, + Properties: s.Properties, + Tags: s.Tags, + } +} + +var _ json.Marshaler = MLTableData{} + +func (s MLTableData) MarshalJSON() ([]byte, error) { + type wrapper MLTableData + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MLTableData: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MLTableData: %+v", err) + } + + decoded["dataType"] = "mltable" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MLTableData: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_pendinguploadcredentialdto.go b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_pendinguploadcredentialdto.go new file mode 100644 index 00000000000..81ff1aaaf51 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_pendinguploadcredentialdto.go @@ -0,0 +1,75 @@ +package dataversionregistry + +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 PendingUploadCredentialDto interface { + PendingUploadCredentialDto() BasePendingUploadCredentialDtoImpl +} + +var _ PendingUploadCredentialDto = BasePendingUploadCredentialDtoImpl{} + +type BasePendingUploadCredentialDtoImpl struct { + CredentialType PendingUploadCredentialType `json:"credentialType"` +} + +func (s BasePendingUploadCredentialDtoImpl) PendingUploadCredentialDto() BasePendingUploadCredentialDtoImpl { + return s +} + +var _ PendingUploadCredentialDto = RawPendingUploadCredentialDtoImpl{} + +// RawPendingUploadCredentialDtoImpl 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 RawPendingUploadCredentialDtoImpl struct { + pendingUploadCredentialDto BasePendingUploadCredentialDtoImpl + Type string + Values map[string]interface{} +} + +func (s RawPendingUploadCredentialDtoImpl) PendingUploadCredentialDto() BasePendingUploadCredentialDtoImpl { + return s.pendingUploadCredentialDto +} + +func UnmarshalPendingUploadCredentialDtoImplementation(input []byte) (PendingUploadCredentialDto, 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 PendingUploadCredentialDto into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["credentialType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "SAS") { + var out SASCredentialDto + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SASCredentialDto: %+v", err) + } + return out, nil + } + + var parent BasePendingUploadCredentialDtoImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BasePendingUploadCredentialDtoImpl: %+v", err) + } + + return RawPendingUploadCredentialDtoImpl{ + pendingUploadCredentialDto: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_pendinguploadrequestdto.go b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_pendinguploadrequestdto.go new file mode 100644 index 00000000000..c47bcedcb7a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_pendinguploadrequestdto.go @@ -0,0 +1,9 @@ +package dataversionregistry + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PendingUploadRequestDto struct { + PendingUploadId *string `json:"pendingUploadId,omitempty"` + PendingUploadType *PendingUploadType `json:"pendingUploadType,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_pendinguploadresponsedto.go b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_pendinguploadresponsedto.go new file mode 100644 index 00000000000..3947e07fc62 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_pendinguploadresponsedto.go @@ -0,0 +1,10 @@ +package dataversionregistry + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PendingUploadResponseDto struct { + BlobReferenceForConsumption *BlobReferenceForConsumptionDto `json:"blobReferenceForConsumption,omitempty"` + PendingUploadId *string `json:"pendingUploadId,omitempty"` + PendingUploadType *PendingUploadType `json:"pendingUploadType,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_sascredentialdto.go b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_sascredentialdto.go new file mode 100644 index 00000000000..8b4b52be918 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_sascredentialdto.go @@ -0,0 +1,50 @@ +package dataversionregistry + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PendingUploadCredentialDto = SASCredentialDto{} + +type SASCredentialDto struct { + SasUri *string `json:"sasUri,omitempty"` + + // Fields inherited from PendingUploadCredentialDto + + CredentialType PendingUploadCredentialType `json:"credentialType"` +} + +func (s SASCredentialDto) PendingUploadCredentialDto() BasePendingUploadCredentialDtoImpl { + return BasePendingUploadCredentialDtoImpl{ + CredentialType: s.CredentialType, + } +} + +var _ json.Marshaler = SASCredentialDto{} + +func (s SASCredentialDto) MarshalJSON() ([]byte, error) { + type wrapper SASCredentialDto + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SASCredentialDto: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SASCredentialDto: %+v", err) + } + + decoded["credentialType"] = "SAS" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SASCredentialDto: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_urifiledataversion.go b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_urifiledataversion.go new file mode 100644 index 00000000000..d1b56bc10c4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_urifiledataversion.go @@ -0,0 +1,61 @@ +package dataversionregistry + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DataVersionBase = UriFileDataVersion{} + +type UriFileDataVersion struct { + + // Fields inherited from DataVersionBase + + DataType DataType `json:"dataType"` + DataUri string `json:"dataUri"` + Description *string `json:"description,omitempty"` + IsAnonymous *bool `json:"isAnonymous,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +func (s UriFileDataVersion) DataVersionBase() BaseDataVersionBaseImpl { + return BaseDataVersionBaseImpl{ + DataType: s.DataType, + DataUri: s.DataUri, + Description: s.Description, + IsAnonymous: s.IsAnonymous, + IsArchived: s.IsArchived, + Properties: s.Properties, + Tags: s.Tags, + } +} + +var _ json.Marshaler = UriFileDataVersion{} + +func (s UriFileDataVersion) MarshalJSON() ([]byte, error) { + type wrapper UriFileDataVersion + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling UriFileDataVersion: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling UriFileDataVersion: %+v", err) + } + + decoded["dataType"] = "uri_file" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling UriFileDataVersion: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_urifolderdataversion.go b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_urifolderdataversion.go new file mode 100644 index 00000000000..63814cf2f54 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/model_urifolderdataversion.go @@ -0,0 +1,61 @@ +package dataversionregistry + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DataVersionBase = UriFolderDataVersion{} + +type UriFolderDataVersion struct { + + // Fields inherited from DataVersionBase + + DataType DataType `json:"dataType"` + DataUri string `json:"dataUri"` + Description *string `json:"description,omitempty"` + IsAnonymous *bool `json:"isAnonymous,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +func (s UriFolderDataVersion) DataVersionBase() BaseDataVersionBaseImpl { + return BaseDataVersionBaseImpl{ + DataType: s.DataType, + DataUri: s.DataUri, + Description: s.Description, + IsAnonymous: s.IsAnonymous, + IsArchived: s.IsArchived, + Properties: s.Properties, + Tags: s.Tags, + } +} + +var _ json.Marshaler = UriFolderDataVersion{} + +func (s UriFolderDataVersion) MarshalJSON() ([]byte, error) { + type wrapper UriFolderDataVersion + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling UriFolderDataVersion: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling UriFolderDataVersion: %+v", err) + } + + decoded["dataType"] = "uri_folder" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling UriFolderDataVersion: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/predicates.go b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/predicates.go new file mode 100644 index 00000000000..b3559d5bc54 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/predicates.go @@ -0,0 +1,27 @@ +package dataversionregistry + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataVersionBaseResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p DataVersionBaseResourceOperationPredicate) Matches(input DataVersionBaseResource) 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/machinelearningservices/2025-04-01/dataversionregistry/version.go b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/version.go new file mode 100644 index 00000000000..c7ea561cab8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/dataversionregistry/version.go @@ -0,0 +1,10 @@ +package dataversionregistry + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/dataversionregistry/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/README.md b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/README.md new file mode 100644 index 00000000000..d92d641bbb4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/README.md @@ -0,0 +1,152 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/environmentcontainer` Documentation + +The `environmentcontainer` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/environmentcontainer" +``` + + +### Client Initialization + +```go +client := environmentcontainer.NewEnvironmentContainerClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `EnvironmentContainerClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := environmentcontainer.NewEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "environmentName") + +payload := environmentcontainer.EnvironmentContainerResource{ + // ... +} + + +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: `EnvironmentContainerClient.Delete` + +```go +ctx := context.TODO() +id := environmentcontainer.NewEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "environmentName") + +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: `EnvironmentContainerClient.Get` + +```go +ctx := context.TODO() +id := environmentcontainer.NewEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "environmentName") + +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: `EnvironmentContainerClient.List` + +```go +ctx := context.TODO() +id := environmentcontainer.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +// alternatively `client.List(ctx, id, environmentcontainer.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, environmentcontainer.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `EnvironmentContainerClient.RegistryEnvironmentContainersCreateOrUpdate` + +```go +ctx := context.TODO() +id := environmentcontainer.NewRegistryEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "environmentName") + +payload := environmentcontainer.EnvironmentContainerResource{ + // ... +} + + +if err := client.RegistryEnvironmentContainersCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `EnvironmentContainerClient.RegistryEnvironmentContainersDelete` + +```go +ctx := context.TODO() +id := environmentcontainer.NewRegistryEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "environmentName") + +if err := client.RegistryEnvironmentContainersDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `EnvironmentContainerClient.RegistryEnvironmentContainersGet` + +```go +ctx := context.TODO() +id := environmentcontainer.NewRegistryEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "environmentName") + +read, err := client.RegistryEnvironmentContainersGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `EnvironmentContainerClient.RegistryEnvironmentContainersList` + +```go +ctx := context.TODO() +id := environmentcontainer.NewRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName") + +// alternatively `client.RegistryEnvironmentContainersList(ctx, id, environmentcontainer.DefaultRegistryEnvironmentContainersListOperationOptions())` can be used to do batched pagination +items, err := client.RegistryEnvironmentContainersListComplete(ctx, id, environmentcontainer.DefaultRegistryEnvironmentContainersListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/client.go b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/client.go new file mode 100644 index 00000000000..c93ae001da9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/client.go @@ -0,0 +1,26 @@ +package environmentcontainer + +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 EnvironmentContainerClient struct { + Client *resourcemanager.Client +} + +func NewEnvironmentContainerClientWithBaseURI(sdkApi sdkEnv.Api) (*EnvironmentContainerClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "environmentcontainer", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating EnvironmentContainerClient: %+v", err) + } + + return &EnvironmentContainerClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/constants.go b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/constants.go new file mode 100644 index 00000000000..1637eac4dde --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/constants.go @@ -0,0 +1,107 @@ +package environmentcontainer + +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 AssetProvisioningState string + +const ( + AssetProvisioningStateCanceled AssetProvisioningState = "Canceled" + AssetProvisioningStateCreating AssetProvisioningState = "Creating" + AssetProvisioningStateDeleting AssetProvisioningState = "Deleting" + AssetProvisioningStateFailed AssetProvisioningState = "Failed" + AssetProvisioningStateSucceeded AssetProvisioningState = "Succeeded" + AssetProvisioningStateUpdating AssetProvisioningState = "Updating" +) + +func PossibleValuesForAssetProvisioningState() []string { + return []string{ + string(AssetProvisioningStateCanceled), + string(AssetProvisioningStateCreating), + string(AssetProvisioningStateDeleting), + string(AssetProvisioningStateFailed), + string(AssetProvisioningStateSucceeded), + string(AssetProvisioningStateUpdating), + } +} + +func (s *AssetProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAssetProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAssetProvisioningState(input string) (*AssetProvisioningState, error) { + vals := map[string]AssetProvisioningState{ + "canceled": AssetProvisioningStateCanceled, + "creating": AssetProvisioningStateCreating, + "deleting": AssetProvisioningStateDeleting, + "failed": AssetProvisioningStateFailed, + "succeeded": AssetProvisioningStateSucceeded, + "updating": AssetProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AssetProvisioningState(input) + return &out, nil +} + +type ListViewType string + +const ( + ListViewTypeActiveOnly ListViewType = "ActiveOnly" + ListViewTypeAll ListViewType = "All" + ListViewTypeArchivedOnly ListViewType = "ArchivedOnly" +) + +func PossibleValuesForListViewType() []string { + return []string{ + string(ListViewTypeActiveOnly), + string(ListViewTypeAll), + string(ListViewTypeArchivedOnly), + } +} + +func (s *ListViewType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseListViewType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseListViewType(input string) (*ListViewType, error) { + vals := map[string]ListViewType{ + "activeonly": ListViewTypeActiveOnly, + "all": ListViewTypeAll, + "archivedonly": ListViewTypeArchivedOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ListViewType(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/id_environment.go b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/id_environment.go new file mode 100644 index 00000000000..31458129d5d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/id_environment.go @@ -0,0 +1,139 @@ +package environmentcontainer + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&EnvironmentId{}) +} + +var _ resourceids.ResourceId = &EnvironmentId{} + +// EnvironmentId is a struct representing the Resource ID for a Environment +type EnvironmentId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + EnvironmentName string +} + +// NewEnvironmentID returns a new EnvironmentId struct +func NewEnvironmentID(subscriptionId string, resourceGroupName string, workspaceName string, environmentName string) EnvironmentId { + return EnvironmentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + EnvironmentName: environmentName, + } +} + +// ParseEnvironmentID parses 'input' into a EnvironmentId +func ParseEnvironmentID(input string) (*EnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&EnvironmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := EnvironmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseEnvironmentIDInsensitively parses 'input' case-insensitively into a EnvironmentId +// note: this method should only be used for API response data and not user input +func ParseEnvironmentIDInsensitively(input string) (*EnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&EnvironmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := EnvironmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *EnvironmentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.EnvironmentName, ok = input.Parsed["environmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "environmentName", input) + } + + return nil +} + +// ValidateEnvironmentID checks that 'input' can be parsed as a Environment ID +func ValidateEnvironmentID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseEnvironmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Environment ID +func (id EnvironmentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/environments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.EnvironmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Environment ID +func (id EnvironmentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticEnvironments", "environments", "environments"), + resourceids.UserSpecifiedSegment("environmentName", "environmentName"), + } +} + +// String returns a human-readable description of this Environment ID +func (id EnvironmentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Environment Name: %q", id.EnvironmentName), + } + return fmt.Sprintf("Environment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/id_environment_test.go b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/id_environment_test.go new file mode 100644 index 00000000000..c8633ca6192 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/id_environment_test.go @@ -0,0 +1,327 @@ +package environmentcontainer + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &EnvironmentId{} + +func TestNewEnvironmentID(t *testing.T) { + id := NewEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "environmentName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.EnvironmentName != "environmentName" { + t.Fatalf("Expected %q but got %q for Segment 'EnvironmentName'", id.EnvironmentName, "environmentName") + } +} + +func TestFormatEnvironmentID(t *testing.T) { + actual := NewEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "environmentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/environments/environmentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseEnvironmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *EnvironmentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/environments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/environments/environmentName", + Expected: &EnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + EnvironmentName: "environmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/environments/environmentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseEnvironmentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.EnvironmentName != v.Expected.EnvironmentName { + t.Fatalf("Expected %q but got %q for EnvironmentName", v.Expected.EnvironmentName, actual.EnvironmentName) + } + + } +} + +func TestParseEnvironmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *EnvironmentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/environments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/eNvIrOnMeNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/environments/environmentName", + Expected: &EnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + EnvironmentName: "environmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/environments/environmentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/eNvIrOnMeNtS/eNvIrOnMeNtNaMe", + Expected: &EnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + EnvironmentName: "eNvIrOnMeNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/eNvIrOnMeNtS/eNvIrOnMeNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseEnvironmentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.EnvironmentName != v.Expected.EnvironmentName { + t.Fatalf("Expected %q but got %q for EnvironmentName", v.Expected.EnvironmentName, actual.EnvironmentName) + } + + } +} + +func TestSegmentsForEnvironmentId(t *testing.T) { + segments := EnvironmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("EnvironmentId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/id_registry.go b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/id_registry.go new file mode 100644 index 00000000000..a1745358053 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/id_registry.go @@ -0,0 +1,130 @@ +package environmentcontainer + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RegistryId{}) +} + +var _ resourceids.ResourceId = &RegistryId{} + +// RegistryId is a struct representing the Resource ID for a Registry +type RegistryId struct { + SubscriptionId string + ResourceGroupName string + RegistryName string +} + +// NewRegistryID returns a new RegistryId struct +func NewRegistryID(subscriptionId string, resourceGroupName string, registryName string) RegistryId { + return RegistryId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RegistryName: registryName, + } +} + +// ParseRegistryID parses 'input' into a RegistryId +func ParseRegistryID(input string) (*RegistryId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRegistryIDInsensitively parses 'input' case-insensitively into a RegistryId +// note: this method should only be used for API response data and not user input +func ParseRegistryIDInsensitively(input string) (*RegistryId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RegistryId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RegistryName, ok = input.Parsed["registryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "registryName", input) + } + + return nil +} + +// ValidateRegistryID checks that 'input' can be parsed as a Registry ID +func ValidateRegistryID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRegistryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Registry ID +func (id RegistryId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/registries/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RegistryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Registry ID +func (id RegistryId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticRegistries", "registries", "registries"), + resourceids.UserSpecifiedSegment("registryName", "registryName"), + } +} + +// String returns a human-readable description of this Registry ID +func (id RegistryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Registry Name: %q", id.RegistryName), + } + return fmt.Sprintf("Registry (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/id_registry_test.go b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/id_registry_test.go new file mode 100644 index 00000000000..c2a6fc673a2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/id_registry_test.go @@ -0,0 +1,282 @@ +package environmentcontainer + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RegistryId{} + +func TestNewRegistryID(t *testing.T) { + id := NewRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RegistryName != "registryName" { + t.Fatalf("Expected %q but got %q for Segment 'RegistryName'", id.RegistryName, "registryName") + } +} + +func TestFormatRegistryID(t *testing.T) { + actual := NewRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRegistryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Expected: &RegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + } +} + +func TestParseRegistryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Expected: &RegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE", + Expected: &RegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RegistryName: "rEgIsTrYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + } +} + +func TestSegmentsForRegistryId(t *testing.T) { + segments := RegistryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RegistryId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/id_registryenvironment.go b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/id_registryenvironment.go new file mode 100644 index 00000000000..13c2a862353 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/id_registryenvironment.go @@ -0,0 +1,139 @@ +package environmentcontainer + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RegistryEnvironmentId{}) +} + +var _ resourceids.ResourceId = &RegistryEnvironmentId{} + +// RegistryEnvironmentId is a struct representing the Resource ID for a Registry Environment +type RegistryEnvironmentId struct { + SubscriptionId string + ResourceGroupName string + RegistryName string + EnvironmentName string +} + +// NewRegistryEnvironmentID returns a new RegistryEnvironmentId struct +func NewRegistryEnvironmentID(subscriptionId string, resourceGroupName string, registryName string, environmentName string) RegistryEnvironmentId { + return RegistryEnvironmentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RegistryName: registryName, + EnvironmentName: environmentName, + } +} + +// ParseRegistryEnvironmentID parses 'input' into a RegistryEnvironmentId +func ParseRegistryEnvironmentID(input string) (*RegistryEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryEnvironmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryEnvironmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRegistryEnvironmentIDInsensitively parses 'input' case-insensitively into a RegistryEnvironmentId +// note: this method should only be used for API response data and not user input +func ParseRegistryEnvironmentIDInsensitively(input string) (*RegistryEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryEnvironmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryEnvironmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RegistryEnvironmentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RegistryName, ok = input.Parsed["registryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "registryName", input) + } + + if id.EnvironmentName, ok = input.Parsed["environmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "environmentName", input) + } + + return nil +} + +// ValidateRegistryEnvironmentID checks that 'input' can be parsed as a Registry Environment ID +func ValidateRegistryEnvironmentID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRegistryEnvironmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Registry Environment ID +func (id RegistryEnvironmentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/registries/%s/environments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RegistryName, id.EnvironmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Registry Environment ID +func (id RegistryEnvironmentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticRegistries", "registries", "registries"), + resourceids.UserSpecifiedSegment("registryName", "registryName"), + resourceids.StaticSegment("staticEnvironments", "environments", "environments"), + resourceids.UserSpecifiedSegment("environmentName", "environmentName"), + } +} + +// String returns a human-readable description of this Registry Environment ID +func (id RegistryEnvironmentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Registry Name: %q", id.RegistryName), + fmt.Sprintf("Environment Name: %q", id.EnvironmentName), + } + return fmt.Sprintf("Registry Environment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/id_registryenvironment_test.go b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/id_registryenvironment_test.go new file mode 100644 index 00000000000..b0cc80614c8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/id_registryenvironment_test.go @@ -0,0 +1,327 @@ +package environmentcontainer + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RegistryEnvironmentId{} + +func TestNewRegistryEnvironmentID(t *testing.T) { + id := NewRegistryEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "environmentName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RegistryName != "registryName" { + t.Fatalf("Expected %q but got %q for Segment 'RegistryName'", id.RegistryName, "registryName") + } + + if id.EnvironmentName != "environmentName" { + t.Fatalf("Expected %q but got %q for Segment 'EnvironmentName'", id.EnvironmentName, "environmentName") + } +} + +func TestFormatRegistryEnvironmentID(t *testing.T) { + actual := NewRegistryEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "environmentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/environments/environmentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRegistryEnvironmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryEnvironmentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/environments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/environments/environmentName", + Expected: &RegistryEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + EnvironmentName: "environmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/environments/environmentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryEnvironmentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.EnvironmentName != v.Expected.EnvironmentName { + t.Fatalf("Expected %q but got %q for EnvironmentName", v.Expected.EnvironmentName, actual.EnvironmentName) + } + + } +} + +func TestParseRegistryEnvironmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryEnvironmentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/environments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/eNvIrOnMeNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/environments/environmentName", + Expected: &RegistryEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + EnvironmentName: "environmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/environments/environmentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/eNvIrOnMeNtS/eNvIrOnMeNtNaMe", + Expected: &RegistryEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RegistryName: "rEgIsTrYnAmE", + EnvironmentName: "eNvIrOnMeNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/eNvIrOnMeNtS/eNvIrOnMeNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryEnvironmentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.EnvironmentName != v.Expected.EnvironmentName { + t.Fatalf("Expected %q but got %q for EnvironmentName", v.Expected.EnvironmentName, actual.EnvironmentName) + } + + } +} + +func TestSegmentsForRegistryEnvironmentId(t *testing.T) { + segments := RegistryEnvironmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RegistryEnvironmentId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/id_workspace.go b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/id_workspace.go new file mode 100644 index 00000000000..dee0f6b5553 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/id_workspace.go @@ -0,0 +1,130 @@ +package environmentcontainer + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/id_workspace_test.go b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/id_workspace_test.go new file mode 100644 index 00000000000..55c55c8b3ba --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/id_workspace_test.go @@ -0,0 +1,282 @@ +package environmentcontainer + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/method_createorupdate.go b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/method_createorupdate.go new file mode 100644 index 00000000000..3c60b94267a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/method_createorupdate.go @@ -0,0 +1,58 @@ +package environmentcontainer + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *EnvironmentContainerResource +} + +// CreateOrUpdate ... +func (c EnvironmentContainerClient) CreateOrUpdate(ctx context.Context, id EnvironmentId, input EnvironmentContainerResource) (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 EnvironmentContainerResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/method_delete.go b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/method_delete.go new file mode 100644 index 00000000000..36c6833fb22 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/method_delete.go @@ -0,0 +1,47 @@ +package environmentcontainer + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 EnvironmentContainerClient) Delete(ctx context.Context, id EnvironmentId) (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/machinelearningservices/2025-04-01/environmentcontainer/method_get.go b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/method_get.go new file mode 100644 index 00000000000..d8ef1c6600c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/method_get.go @@ -0,0 +1,53 @@ +package environmentcontainer + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *EnvironmentContainerResource +} + +// Get ... +func (c EnvironmentContainerClient) Get(ctx context.Context, id EnvironmentId) (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 EnvironmentContainerResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/method_list.go b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/method_list.go new file mode 100644 index 00000000000..9c37a1f7173 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/method_list.go @@ -0,0 +1,138 @@ +package environmentcontainer + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]EnvironmentContainerResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []EnvironmentContainerResource +} + +type ListOperationOptions struct { + ListViewType *ListViewType + Skip *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.ListViewType != nil { + out.Append("listViewType", fmt.Sprintf("%v", *o.ListViewType)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + 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 EnvironmentContainerClient) List(ctx context.Context, id WorkspaceId, 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/environments", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]EnvironmentContainerResource `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 EnvironmentContainerClient) ListComplete(ctx context.Context, id WorkspaceId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, EnvironmentContainerResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c EnvironmentContainerClient) ListCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, options ListOperationOptions, predicate EnvironmentContainerResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]EnvironmentContainerResource, 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/machinelearningservices/2025-04-01/environmentcontainer/method_registryenvironmentcontainerscreateorupdate.go b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/method_registryenvironmentcontainerscreateorupdate.go new file mode 100644 index 00000000000..1f8a5d57b03 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/method_registryenvironmentcontainerscreateorupdate.go @@ -0,0 +1,75 @@ +package environmentcontainer + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryEnvironmentContainersCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *EnvironmentContainerResource +} + +// RegistryEnvironmentContainersCreateOrUpdate ... +func (c EnvironmentContainerClient) RegistryEnvironmentContainersCreateOrUpdate(ctx context.Context, id RegistryEnvironmentId, input EnvironmentContainerResource) (result RegistryEnvironmentContainersCreateOrUpdateOperationResponse, 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 +} + +// RegistryEnvironmentContainersCreateOrUpdateThenPoll performs RegistryEnvironmentContainersCreateOrUpdate then polls until it's completed +func (c EnvironmentContainerClient) RegistryEnvironmentContainersCreateOrUpdateThenPoll(ctx context.Context, id RegistryEnvironmentId, input EnvironmentContainerResource) error { + result, err := c.RegistryEnvironmentContainersCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RegistryEnvironmentContainersCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegistryEnvironmentContainersCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/method_registryenvironmentcontainersdelete.go b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/method_registryenvironmentcontainersdelete.go new file mode 100644 index 00000000000..42d485d132b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/method_registryenvironmentcontainersdelete.go @@ -0,0 +1,71 @@ +package environmentcontainer + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryEnvironmentContainersDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RegistryEnvironmentContainersDelete ... +func (c EnvironmentContainerClient) RegistryEnvironmentContainersDelete(ctx context.Context, id RegistryEnvironmentId) (result RegistryEnvironmentContainersDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RegistryEnvironmentContainersDeleteThenPoll performs RegistryEnvironmentContainersDelete then polls until it's completed +func (c EnvironmentContainerClient) RegistryEnvironmentContainersDeleteThenPoll(ctx context.Context, id RegistryEnvironmentId) error { + result, err := c.RegistryEnvironmentContainersDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing RegistryEnvironmentContainersDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegistryEnvironmentContainersDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/method_registryenvironmentcontainersget.go b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/method_registryenvironmentcontainersget.go new file mode 100644 index 00000000000..718666f0727 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/method_registryenvironmentcontainersget.go @@ -0,0 +1,53 @@ +package environmentcontainer + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryEnvironmentContainersGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *EnvironmentContainerResource +} + +// RegistryEnvironmentContainersGet ... +func (c EnvironmentContainerClient) RegistryEnvironmentContainersGet(ctx context.Context, id RegistryEnvironmentId) (result RegistryEnvironmentContainersGetOperationResponse, 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 EnvironmentContainerResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/method_registryenvironmentcontainerslist.go b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/method_registryenvironmentcontainerslist.go new file mode 100644 index 00000000000..16fe9c75ece --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/method_registryenvironmentcontainerslist.go @@ -0,0 +1,138 @@ +package environmentcontainer + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryEnvironmentContainersListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]EnvironmentContainerResource +} + +type RegistryEnvironmentContainersListCompleteResult struct { + LatestHttpResponse *http.Response + Items []EnvironmentContainerResource +} + +type RegistryEnvironmentContainersListOperationOptions struct { + ListViewType *ListViewType + Skip *string +} + +func DefaultRegistryEnvironmentContainersListOperationOptions() RegistryEnvironmentContainersListOperationOptions { + return RegistryEnvironmentContainersListOperationOptions{} +} + +func (o RegistryEnvironmentContainersListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RegistryEnvironmentContainersListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RegistryEnvironmentContainersListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ListViewType != nil { + out.Append("listViewType", fmt.Sprintf("%v", *o.ListViewType)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + return &out +} + +type RegistryEnvironmentContainersListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *RegistryEnvironmentContainersListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// RegistryEnvironmentContainersList ... +func (c EnvironmentContainerClient) RegistryEnvironmentContainersList(ctx context.Context, id RegistryId, options RegistryEnvironmentContainersListOperationOptions) (result RegistryEnvironmentContainersListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &RegistryEnvironmentContainersListCustomPager{}, + Path: fmt.Sprintf("%s/environments", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]EnvironmentContainerResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RegistryEnvironmentContainersListComplete retrieves all the results into a single object +func (c EnvironmentContainerClient) RegistryEnvironmentContainersListComplete(ctx context.Context, id RegistryId, options RegistryEnvironmentContainersListOperationOptions) (RegistryEnvironmentContainersListCompleteResult, error) { + return c.RegistryEnvironmentContainersListCompleteMatchingPredicate(ctx, id, options, EnvironmentContainerResourceOperationPredicate{}) +} + +// RegistryEnvironmentContainersListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c EnvironmentContainerClient) RegistryEnvironmentContainersListCompleteMatchingPredicate(ctx context.Context, id RegistryId, options RegistryEnvironmentContainersListOperationOptions, predicate EnvironmentContainerResourceOperationPredicate) (result RegistryEnvironmentContainersListCompleteResult, err error) { + items := make([]EnvironmentContainerResource, 0) + + resp, err := c.RegistryEnvironmentContainersList(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 = RegistryEnvironmentContainersListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/model_environmentcontainer.go b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/model_environmentcontainer.go new file mode 100644 index 00000000000..2ecb80ec045 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/model_environmentcontainer.go @@ -0,0 +1,14 @@ +package environmentcontainer + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnvironmentContainer struct { + Description *string `json:"description,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + LatestVersion *string `json:"latestVersion,omitempty"` + NextVersion *string `json:"nextVersion,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ProvisioningState *AssetProvisioningState `json:"provisioningState,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/model_environmentcontainerresource.go b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/model_environmentcontainerresource.go new file mode 100644 index 00000000000..4135119472a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/model_environmentcontainerresource.go @@ -0,0 +1,16 @@ +package environmentcontainer + +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 EnvironmentContainerResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties EnvironmentContainer `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/predicates.go b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/predicates.go new file mode 100644 index 00000000000..1b662862d6e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/predicates.go @@ -0,0 +1,27 @@ +package environmentcontainer + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnvironmentContainerResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p EnvironmentContainerResourceOperationPredicate) Matches(input EnvironmentContainerResource) 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/machinelearningservices/2025-04-01/environmentcontainer/version.go b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/version.go new file mode 100644 index 00000000000..2d82c7e6fb4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentcontainer/version.go @@ -0,0 +1,10 @@ +package environmentcontainer + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/environmentcontainer/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentversion/README.md b/resource-manager/machinelearningservices/2025-04-01/environmentversion/README.md new file mode 100644 index 00000000000..81a223dde7a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/README.md @@ -0,0 +1,169 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/environmentversion` Documentation + +The `environmentversion` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/environmentversion" +``` + + +### Client Initialization + +```go +client := environmentversion.NewEnvironmentVersionClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `EnvironmentVersionClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := environmentversion.NewEnvironmentVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "environmentName", "versionName") + +payload := environmentversion.EnvironmentVersionResource{ + // ... +} + + +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: `EnvironmentVersionClient.Delete` + +```go +ctx := context.TODO() +id := environmentversion.NewEnvironmentVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "environmentName", "versionName") + +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: `EnvironmentVersionClient.Get` + +```go +ctx := context.TODO() +id := environmentversion.NewEnvironmentVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "environmentName", "versionName") + +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: `EnvironmentVersionClient.List` + +```go +ctx := context.TODO() +id := environmentversion.NewEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "environmentName") + +// alternatively `client.List(ctx, id, environmentversion.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, environmentversion.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `EnvironmentVersionClient.Publish` + +```go +ctx := context.TODO() +id := environmentversion.NewEnvironmentVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "environmentName", "versionName") + +payload := environmentversion.DestinationAsset{ + // ... +} + + +if err := client.PublishThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `EnvironmentVersionClient.RegistryEnvironmentVersionsCreateOrUpdate` + +```go +ctx := context.TODO() +id := environmentversion.NewRegistryEnvironmentVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "environmentName", "versionName") + +payload := environmentversion.EnvironmentVersionResource{ + // ... +} + + +if err := client.RegistryEnvironmentVersionsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `EnvironmentVersionClient.RegistryEnvironmentVersionsDelete` + +```go +ctx := context.TODO() +id := environmentversion.NewRegistryEnvironmentVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "environmentName", "versionName") + +if err := client.RegistryEnvironmentVersionsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `EnvironmentVersionClient.RegistryEnvironmentVersionsGet` + +```go +ctx := context.TODO() +id := environmentversion.NewRegistryEnvironmentVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "environmentName", "versionName") + +read, err := client.RegistryEnvironmentVersionsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `EnvironmentVersionClient.RegistryEnvironmentVersionsList` + +```go +ctx := context.TODO() +id := environmentversion.NewRegistryEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "environmentName") + +// alternatively `client.RegistryEnvironmentVersionsList(ctx, id, environmentversion.DefaultRegistryEnvironmentVersionsListOperationOptions())` can be used to do batched pagination +items, err := client.RegistryEnvironmentVersionsListComplete(ctx, id, environmentversion.DefaultRegistryEnvironmentVersionsListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentversion/client.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/client.go new file mode 100644 index 00000000000..5d10a29049b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/client.go @@ -0,0 +1,26 @@ +package environmentversion + +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 EnvironmentVersionClient struct { + Client *resourcemanager.Client +} + +func NewEnvironmentVersionClientWithBaseURI(sdkApi sdkEnv.Api) (*EnvironmentVersionClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "environmentversion", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating EnvironmentVersionClient: %+v", err) + } + + return &EnvironmentVersionClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentversion/constants.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/constants.go new file mode 100644 index 00000000000..f7ea4ef55c4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/constants.go @@ -0,0 +1,230 @@ +package environmentversion + +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 AssetProvisioningState string + +const ( + AssetProvisioningStateCanceled AssetProvisioningState = "Canceled" + AssetProvisioningStateCreating AssetProvisioningState = "Creating" + AssetProvisioningStateDeleting AssetProvisioningState = "Deleting" + AssetProvisioningStateFailed AssetProvisioningState = "Failed" + AssetProvisioningStateSucceeded AssetProvisioningState = "Succeeded" + AssetProvisioningStateUpdating AssetProvisioningState = "Updating" +) + +func PossibleValuesForAssetProvisioningState() []string { + return []string{ + string(AssetProvisioningStateCanceled), + string(AssetProvisioningStateCreating), + string(AssetProvisioningStateDeleting), + string(AssetProvisioningStateFailed), + string(AssetProvisioningStateSucceeded), + string(AssetProvisioningStateUpdating), + } +} + +func (s *AssetProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAssetProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAssetProvisioningState(input string) (*AssetProvisioningState, error) { + vals := map[string]AssetProvisioningState{ + "canceled": AssetProvisioningStateCanceled, + "creating": AssetProvisioningStateCreating, + "deleting": AssetProvisioningStateDeleting, + "failed": AssetProvisioningStateFailed, + "succeeded": AssetProvisioningStateSucceeded, + "updating": AssetProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AssetProvisioningState(input) + return &out, nil +} + +type AutoRebuildSetting string + +const ( + AutoRebuildSettingDisabled AutoRebuildSetting = "Disabled" + AutoRebuildSettingOnBaseImageUpdate AutoRebuildSetting = "OnBaseImageUpdate" +) + +func PossibleValuesForAutoRebuildSetting() []string { + return []string{ + string(AutoRebuildSettingDisabled), + string(AutoRebuildSettingOnBaseImageUpdate), + } +} + +func (s *AutoRebuildSetting) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutoRebuildSetting(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutoRebuildSetting(input string) (*AutoRebuildSetting, error) { + vals := map[string]AutoRebuildSetting{ + "disabled": AutoRebuildSettingDisabled, + "onbaseimageupdate": AutoRebuildSettingOnBaseImageUpdate, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AutoRebuildSetting(input) + return &out, nil +} + +type EnvironmentType string + +const ( + EnvironmentTypeCurated EnvironmentType = "Curated" + EnvironmentTypeUserCreated EnvironmentType = "UserCreated" +) + +func PossibleValuesForEnvironmentType() []string { + return []string{ + string(EnvironmentTypeCurated), + string(EnvironmentTypeUserCreated), + } +} + +func (s *EnvironmentType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnvironmentType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEnvironmentType(input string) (*EnvironmentType, error) { + vals := map[string]EnvironmentType{ + "curated": EnvironmentTypeCurated, + "usercreated": EnvironmentTypeUserCreated, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EnvironmentType(input) + return &out, nil +} + +type ListViewType string + +const ( + ListViewTypeActiveOnly ListViewType = "ActiveOnly" + ListViewTypeAll ListViewType = "All" + ListViewTypeArchivedOnly ListViewType = "ArchivedOnly" +) + +func PossibleValuesForListViewType() []string { + return []string{ + string(ListViewTypeActiveOnly), + string(ListViewTypeAll), + string(ListViewTypeArchivedOnly), + } +} + +func (s *ListViewType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseListViewType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseListViewType(input string) (*ListViewType, error) { + vals := map[string]ListViewType{ + "activeonly": ListViewTypeActiveOnly, + "all": ListViewTypeAll, + "archivedonly": ListViewTypeArchivedOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ListViewType(input) + return &out, nil +} + +type OperatingSystemType string + +const ( + OperatingSystemTypeLinux OperatingSystemType = "Linux" + OperatingSystemTypeWindows OperatingSystemType = "Windows" +) + +func PossibleValuesForOperatingSystemType() []string { + return []string{ + string(OperatingSystemTypeLinux), + string(OperatingSystemTypeWindows), + } +} + +func (s *OperatingSystemType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperatingSystemType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOperatingSystemType(input string) (*OperatingSystemType, error) { + vals := map[string]OperatingSystemType{ + "linux": OperatingSystemTypeLinux, + "windows": OperatingSystemTypeWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OperatingSystemType(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentversion/id_environment.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/id_environment.go new file mode 100644 index 00000000000..2d0575da32b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/id_environment.go @@ -0,0 +1,139 @@ +package environmentversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&EnvironmentId{}) +} + +var _ resourceids.ResourceId = &EnvironmentId{} + +// EnvironmentId is a struct representing the Resource ID for a Environment +type EnvironmentId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + EnvironmentName string +} + +// NewEnvironmentID returns a new EnvironmentId struct +func NewEnvironmentID(subscriptionId string, resourceGroupName string, workspaceName string, environmentName string) EnvironmentId { + return EnvironmentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + EnvironmentName: environmentName, + } +} + +// ParseEnvironmentID parses 'input' into a EnvironmentId +func ParseEnvironmentID(input string) (*EnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&EnvironmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := EnvironmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseEnvironmentIDInsensitively parses 'input' case-insensitively into a EnvironmentId +// note: this method should only be used for API response data and not user input +func ParseEnvironmentIDInsensitively(input string) (*EnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&EnvironmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := EnvironmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *EnvironmentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.EnvironmentName, ok = input.Parsed["environmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "environmentName", input) + } + + return nil +} + +// ValidateEnvironmentID checks that 'input' can be parsed as a Environment ID +func ValidateEnvironmentID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseEnvironmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Environment ID +func (id EnvironmentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/environments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.EnvironmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Environment ID +func (id EnvironmentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticEnvironments", "environments", "environments"), + resourceids.UserSpecifiedSegment("environmentName", "environmentName"), + } +} + +// String returns a human-readable description of this Environment ID +func (id EnvironmentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Environment Name: %q", id.EnvironmentName), + } + return fmt.Sprintf("Environment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentversion/id_environment_test.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/id_environment_test.go new file mode 100644 index 00000000000..e4c30775c5d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/id_environment_test.go @@ -0,0 +1,327 @@ +package environmentversion + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &EnvironmentId{} + +func TestNewEnvironmentID(t *testing.T) { + id := NewEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "environmentName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.EnvironmentName != "environmentName" { + t.Fatalf("Expected %q but got %q for Segment 'EnvironmentName'", id.EnvironmentName, "environmentName") + } +} + +func TestFormatEnvironmentID(t *testing.T) { + actual := NewEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "environmentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/environments/environmentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseEnvironmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *EnvironmentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/environments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/environments/environmentName", + Expected: &EnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + EnvironmentName: "environmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/environments/environmentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseEnvironmentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.EnvironmentName != v.Expected.EnvironmentName { + t.Fatalf("Expected %q but got %q for EnvironmentName", v.Expected.EnvironmentName, actual.EnvironmentName) + } + + } +} + +func TestParseEnvironmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *EnvironmentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/environments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/eNvIrOnMeNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/environments/environmentName", + Expected: &EnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + EnvironmentName: "environmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/environments/environmentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/eNvIrOnMeNtS/eNvIrOnMeNtNaMe", + Expected: &EnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + EnvironmentName: "eNvIrOnMeNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/eNvIrOnMeNtS/eNvIrOnMeNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseEnvironmentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.EnvironmentName != v.Expected.EnvironmentName { + t.Fatalf("Expected %q but got %q for EnvironmentName", v.Expected.EnvironmentName, actual.EnvironmentName) + } + + } +} + +func TestSegmentsForEnvironmentId(t *testing.T) { + segments := EnvironmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("EnvironmentId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentversion/id_environmentversion.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/id_environmentversion.go new file mode 100644 index 00000000000..9e4e6dee046 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/id_environmentversion.go @@ -0,0 +1,148 @@ +package environmentversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&EnvironmentVersionId{}) +} + +var _ resourceids.ResourceId = &EnvironmentVersionId{} + +// EnvironmentVersionId is a struct representing the Resource ID for a Environment Version +type EnvironmentVersionId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + EnvironmentName string + VersionName string +} + +// NewEnvironmentVersionID returns a new EnvironmentVersionId struct +func NewEnvironmentVersionID(subscriptionId string, resourceGroupName string, workspaceName string, environmentName string, versionName string) EnvironmentVersionId { + return EnvironmentVersionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + EnvironmentName: environmentName, + VersionName: versionName, + } +} + +// ParseEnvironmentVersionID parses 'input' into a EnvironmentVersionId +func ParseEnvironmentVersionID(input string) (*EnvironmentVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&EnvironmentVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := EnvironmentVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseEnvironmentVersionIDInsensitively parses 'input' case-insensitively into a EnvironmentVersionId +// note: this method should only be used for API response data and not user input +func ParseEnvironmentVersionIDInsensitively(input string) (*EnvironmentVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&EnvironmentVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := EnvironmentVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *EnvironmentVersionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.EnvironmentName, ok = input.Parsed["environmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "environmentName", input) + } + + if id.VersionName, ok = input.Parsed["versionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "versionName", input) + } + + return nil +} + +// ValidateEnvironmentVersionID checks that 'input' can be parsed as a Environment Version ID +func ValidateEnvironmentVersionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseEnvironmentVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Environment Version ID +func (id EnvironmentVersionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/environments/%s/versions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.EnvironmentName, id.VersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Environment Version ID +func (id EnvironmentVersionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticEnvironments", "environments", "environments"), + resourceids.UserSpecifiedSegment("environmentName", "environmentName"), + resourceids.StaticSegment("staticVersions", "versions", "versions"), + resourceids.UserSpecifiedSegment("versionName", "versionName"), + } +} + +// String returns a human-readable description of this Environment Version ID +func (id EnvironmentVersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Environment Name: %q", id.EnvironmentName), + fmt.Sprintf("Version Name: %q", id.VersionName), + } + return fmt.Sprintf("Environment Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentversion/id_environmentversion_test.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/id_environmentversion_test.go new file mode 100644 index 00000000000..6226c5e992b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/id_environmentversion_test.go @@ -0,0 +1,372 @@ +package environmentversion + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &EnvironmentVersionId{} + +func TestNewEnvironmentVersionID(t *testing.T) { + id := NewEnvironmentVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "environmentName", "versionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.EnvironmentName != "environmentName" { + t.Fatalf("Expected %q but got %q for Segment 'EnvironmentName'", id.EnvironmentName, "environmentName") + } + + if id.VersionName != "versionName" { + t.Fatalf("Expected %q but got %q for Segment 'VersionName'", id.VersionName, "versionName") + } +} + +func TestFormatEnvironmentVersionID(t *testing.T) { + actual := NewEnvironmentVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "environmentName", "versionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/environments/environmentName/versions/versionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseEnvironmentVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *EnvironmentVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/environments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/environments/environmentName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/environments/environmentName/versions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/environments/environmentName/versions/versionName", + Expected: &EnvironmentVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + EnvironmentName: "environmentName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/environments/environmentName/versions/versionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseEnvironmentVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.EnvironmentName != v.Expected.EnvironmentName { + t.Fatalf("Expected %q but got %q for EnvironmentName", v.Expected.EnvironmentName, actual.EnvironmentName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestParseEnvironmentVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *EnvironmentVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/environments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/eNvIrOnMeNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/environments/environmentName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/eNvIrOnMeNtS/eNvIrOnMeNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/environments/environmentName/versions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/eNvIrOnMeNtS/eNvIrOnMeNtNaMe/vErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/environments/environmentName/versions/versionName", + Expected: &EnvironmentVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + EnvironmentName: "environmentName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/environments/environmentName/versions/versionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/eNvIrOnMeNtS/eNvIrOnMeNtNaMe/vErSiOnS/vErSiOnNaMe", + Expected: &EnvironmentVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + EnvironmentName: "eNvIrOnMeNtNaMe", + VersionName: "vErSiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/eNvIrOnMeNtS/eNvIrOnMeNtNaMe/vErSiOnS/vErSiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseEnvironmentVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.EnvironmentName != v.Expected.EnvironmentName { + t.Fatalf("Expected %q but got %q for EnvironmentName", v.Expected.EnvironmentName, actual.EnvironmentName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestSegmentsForEnvironmentVersionId(t *testing.T) { + segments := EnvironmentVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("EnvironmentVersionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentversion/id_registryenvironment.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/id_registryenvironment.go new file mode 100644 index 00000000000..dbf6f9f7ae4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/id_registryenvironment.go @@ -0,0 +1,139 @@ +package environmentversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RegistryEnvironmentId{}) +} + +var _ resourceids.ResourceId = &RegistryEnvironmentId{} + +// RegistryEnvironmentId is a struct representing the Resource ID for a Registry Environment +type RegistryEnvironmentId struct { + SubscriptionId string + ResourceGroupName string + RegistryName string + EnvironmentName string +} + +// NewRegistryEnvironmentID returns a new RegistryEnvironmentId struct +func NewRegistryEnvironmentID(subscriptionId string, resourceGroupName string, registryName string, environmentName string) RegistryEnvironmentId { + return RegistryEnvironmentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RegistryName: registryName, + EnvironmentName: environmentName, + } +} + +// ParseRegistryEnvironmentID parses 'input' into a RegistryEnvironmentId +func ParseRegistryEnvironmentID(input string) (*RegistryEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryEnvironmentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryEnvironmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRegistryEnvironmentIDInsensitively parses 'input' case-insensitively into a RegistryEnvironmentId +// note: this method should only be used for API response data and not user input +func ParseRegistryEnvironmentIDInsensitively(input string) (*RegistryEnvironmentId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryEnvironmentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryEnvironmentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RegistryEnvironmentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RegistryName, ok = input.Parsed["registryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "registryName", input) + } + + if id.EnvironmentName, ok = input.Parsed["environmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "environmentName", input) + } + + return nil +} + +// ValidateRegistryEnvironmentID checks that 'input' can be parsed as a Registry Environment ID +func ValidateRegistryEnvironmentID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRegistryEnvironmentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Registry Environment ID +func (id RegistryEnvironmentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/registries/%s/environments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RegistryName, id.EnvironmentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Registry Environment ID +func (id RegistryEnvironmentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticRegistries", "registries", "registries"), + resourceids.UserSpecifiedSegment("registryName", "registryName"), + resourceids.StaticSegment("staticEnvironments", "environments", "environments"), + resourceids.UserSpecifiedSegment("environmentName", "environmentName"), + } +} + +// String returns a human-readable description of this Registry Environment ID +func (id RegistryEnvironmentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Registry Name: %q", id.RegistryName), + fmt.Sprintf("Environment Name: %q", id.EnvironmentName), + } + return fmt.Sprintf("Registry Environment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentversion/id_registryenvironment_test.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/id_registryenvironment_test.go new file mode 100644 index 00000000000..0e2b6c64aac --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/id_registryenvironment_test.go @@ -0,0 +1,327 @@ +package environmentversion + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RegistryEnvironmentId{} + +func TestNewRegistryEnvironmentID(t *testing.T) { + id := NewRegistryEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "environmentName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RegistryName != "registryName" { + t.Fatalf("Expected %q but got %q for Segment 'RegistryName'", id.RegistryName, "registryName") + } + + if id.EnvironmentName != "environmentName" { + t.Fatalf("Expected %q but got %q for Segment 'EnvironmentName'", id.EnvironmentName, "environmentName") + } +} + +func TestFormatRegistryEnvironmentID(t *testing.T) { + actual := NewRegistryEnvironmentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "environmentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/environments/environmentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRegistryEnvironmentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryEnvironmentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/environments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/environments/environmentName", + Expected: &RegistryEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + EnvironmentName: "environmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/environments/environmentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryEnvironmentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.EnvironmentName != v.Expected.EnvironmentName { + t.Fatalf("Expected %q but got %q for EnvironmentName", v.Expected.EnvironmentName, actual.EnvironmentName) + } + + } +} + +func TestParseRegistryEnvironmentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryEnvironmentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/environments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/eNvIrOnMeNtS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/environments/environmentName", + Expected: &RegistryEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + EnvironmentName: "environmentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/environments/environmentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/eNvIrOnMeNtS/eNvIrOnMeNtNaMe", + Expected: &RegistryEnvironmentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RegistryName: "rEgIsTrYnAmE", + EnvironmentName: "eNvIrOnMeNtNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/eNvIrOnMeNtS/eNvIrOnMeNtNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryEnvironmentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.EnvironmentName != v.Expected.EnvironmentName { + t.Fatalf("Expected %q but got %q for EnvironmentName", v.Expected.EnvironmentName, actual.EnvironmentName) + } + + } +} + +func TestSegmentsForRegistryEnvironmentId(t *testing.T) { + segments := RegistryEnvironmentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RegistryEnvironmentId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentversion/id_registryenvironmentversion.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/id_registryenvironmentversion.go new file mode 100644 index 00000000000..0740cbb7dc1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/id_registryenvironmentversion.go @@ -0,0 +1,148 @@ +package environmentversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RegistryEnvironmentVersionId{}) +} + +var _ resourceids.ResourceId = &RegistryEnvironmentVersionId{} + +// RegistryEnvironmentVersionId is a struct representing the Resource ID for a Registry Environment Version +type RegistryEnvironmentVersionId struct { + SubscriptionId string + ResourceGroupName string + RegistryName string + EnvironmentName string + VersionName string +} + +// NewRegistryEnvironmentVersionID returns a new RegistryEnvironmentVersionId struct +func NewRegistryEnvironmentVersionID(subscriptionId string, resourceGroupName string, registryName string, environmentName string, versionName string) RegistryEnvironmentVersionId { + return RegistryEnvironmentVersionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RegistryName: registryName, + EnvironmentName: environmentName, + VersionName: versionName, + } +} + +// ParseRegistryEnvironmentVersionID parses 'input' into a RegistryEnvironmentVersionId +func ParseRegistryEnvironmentVersionID(input string) (*RegistryEnvironmentVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryEnvironmentVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryEnvironmentVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRegistryEnvironmentVersionIDInsensitively parses 'input' case-insensitively into a RegistryEnvironmentVersionId +// note: this method should only be used for API response data and not user input +func ParseRegistryEnvironmentVersionIDInsensitively(input string) (*RegistryEnvironmentVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryEnvironmentVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryEnvironmentVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RegistryEnvironmentVersionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RegistryName, ok = input.Parsed["registryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "registryName", input) + } + + if id.EnvironmentName, ok = input.Parsed["environmentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "environmentName", input) + } + + if id.VersionName, ok = input.Parsed["versionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "versionName", input) + } + + return nil +} + +// ValidateRegistryEnvironmentVersionID checks that 'input' can be parsed as a Registry Environment Version ID +func ValidateRegistryEnvironmentVersionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRegistryEnvironmentVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Registry Environment Version ID +func (id RegistryEnvironmentVersionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/registries/%s/environments/%s/versions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RegistryName, id.EnvironmentName, id.VersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Registry Environment Version ID +func (id RegistryEnvironmentVersionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticRegistries", "registries", "registries"), + resourceids.UserSpecifiedSegment("registryName", "registryName"), + resourceids.StaticSegment("staticEnvironments", "environments", "environments"), + resourceids.UserSpecifiedSegment("environmentName", "environmentName"), + resourceids.StaticSegment("staticVersions", "versions", "versions"), + resourceids.UserSpecifiedSegment("versionName", "versionName"), + } +} + +// String returns a human-readable description of this Registry Environment Version ID +func (id RegistryEnvironmentVersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Registry Name: %q", id.RegistryName), + fmt.Sprintf("Environment Name: %q", id.EnvironmentName), + fmt.Sprintf("Version Name: %q", id.VersionName), + } + return fmt.Sprintf("Registry Environment Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentversion/id_registryenvironmentversion_test.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/id_registryenvironmentversion_test.go new file mode 100644 index 00000000000..07c56b6d583 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/id_registryenvironmentversion_test.go @@ -0,0 +1,372 @@ +package environmentversion + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RegistryEnvironmentVersionId{} + +func TestNewRegistryEnvironmentVersionID(t *testing.T) { + id := NewRegistryEnvironmentVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "environmentName", "versionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RegistryName != "registryName" { + t.Fatalf("Expected %q but got %q for Segment 'RegistryName'", id.RegistryName, "registryName") + } + + if id.EnvironmentName != "environmentName" { + t.Fatalf("Expected %q but got %q for Segment 'EnvironmentName'", id.EnvironmentName, "environmentName") + } + + if id.VersionName != "versionName" { + t.Fatalf("Expected %q but got %q for Segment 'VersionName'", id.VersionName, "versionName") + } +} + +func TestFormatRegistryEnvironmentVersionID(t *testing.T) { + actual := NewRegistryEnvironmentVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "environmentName", "versionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/environments/environmentName/versions/versionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRegistryEnvironmentVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryEnvironmentVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/environments", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/environments/environmentName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/environments/environmentName/versions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/environments/environmentName/versions/versionName", + Expected: &RegistryEnvironmentVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + EnvironmentName: "environmentName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/environments/environmentName/versions/versionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryEnvironmentVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.EnvironmentName != v.Expected.EnvironmentName { + t.Fatalf("Expected %q but got %q for EnvironmentName", v.Expected.EnvironmentName, actual.EnvironmentName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestParseRegistryEnvironmentVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryEnvironmentVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/environments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/eNvIrOnMeNtS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/environments/environmentName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/eNvIrOnMeNtS/eNvIrOnMeNtNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/environments/environmentName/versions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/eNvIrOnMeNtS/eNvIrOnMeNtNaMe/vErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/environments/environmentName/versions/versionName", + Expected: &RegistryEnvironmentVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + EnvironmentName: "environmentName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/environments/environmentName/versions/versionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/eNvIrOnMeNtS/eNvIrOnMeNtNaMe/vErSiOnS/vErSiOnNaMe", + Expected: &RegistryEnvironmentVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RegistryName: "rEgIsTrYnAmE", + EnvironmentName: "eNvIrOnMeNtNaMe", + VersionName: "vErSiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/eNvIrOnMeNtS/eNvIrOnMeNtNaMe/vErSiOnS/vErSiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryEnvironmentVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.EnvironmentName != v.Expected.EnvironmentName { + t.Fatalf("Expected %q but got %q for EnvironmentName", v.Expected.EnvironmentName, actual.EnvironmentName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestSegmentsForRegistryEnvironmentVersionId(t *testing.T) { + segments := RegistryEnvironmentVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RegistryEnvironmentVersionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentversion/method_createorupdate.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/method_createorupdate.go new file mode 100644 index 00000000000..9d59df5e453 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/method_createorupdate.go @@ -0,0 +1,58 @@ +package environmentversion + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *EnvironmentVersionResource +} + +// CreateOrUpdate ... +func (c EnvironmentVersionClient) CreateOrUpdate(ctx context.Context, id EnvironmentVersionId, input EnvironmentVersionResource) (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 EnvironmentVersionResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentversion/method_delete.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/method_delete.go new file mode 100644 index 00000000000..57be3c94bc2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/method_delete.go @@ -0,0 +1,47 @@ +package environmentversion + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 EnvironmentVersionClient) Delete(ctx context.Context, id EnvironmentVersionId) (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/machinelearningservices/2025-04-01/environmentversion/method_get.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/method_get.go new file mode 100644 index 00000000000..7563144e740 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/method_get.go @@ -0,0 +1,53 @@ +package environmentversion + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *EnvironmentVersionResource +} + +// Get ... +func (c EnvironmentVersionClient) Get(ctx context.Context, id EnvironmentVersionId) (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 EnvironmentVersionResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentversion/method_list.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/method_list.go new file mode 100644 index 00000000000..2939cc5f60f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/method_list.go @@ -0,0 +1,146 @@ +package environmentversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]EnvironmentVersionResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []EnvironmentVersionResource +} + +type ListOperationOptions struct { + ListViewType *ListViewType + OrderBy *string + Skip *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ListViewType != nil { + out.Append("listViewType", fmt.Sprintf("%v", *o.ListViewType)) + } + if o.OrderBy != nil { + out.Append("$orderBy", fmt.Sprintf("%v", *o.OrderBy)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c EnvironmentVersionClient) List(ctx context.Context, id EnvironmentId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/versions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]EnvironmentVersionResource `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 EnvironmentVersionClient) ListComplete(ctx context.Context, id EnvironmentId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, EnvironmentVersionResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c EnvironmentVersionClient) ListCompleteMatchingPredicate(ctx context.Context, id EnvironmentId, options ListOperationOptions, predicate EnvironmentVersionResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]EnvironmentVersionResource, 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/machinelearningservices/2025-04-01/environmentversion/method_publish.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/method_publish.go new file mode 100644 index 00000000000..cf281c070d2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/method_publish.go @@ -0,0 +1,74 @@ +package environmentversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublishOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Publish ... +func (c EnvironmentVersionClient) Publish(ctx context.Context, id EnvironmentVersionId, input DestinationAsset) (result PublishOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/publish", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// PublishThenPoll performs Publish then polls until it's completed +func (c EnvironmentVersionClient) PublishThenPoll(ctx context.Context, id EnvironmentVersionId, input DestinationAsset) error { + result, err := c.Publish(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Publish: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Publish: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentversion/method_registryenvironmentversionscreateorupdate.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/method_registryenvironmentversionscreateorupdate.go new file mode 100644 index 00000000000..1df57c537e7 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/method_registryenvironmentversionscreateorupdate.go @@ -0,0 +1,75 @@ +package environmentversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryEnvironmentVersionsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *EnvironmentVersionResource +} + +// RegistryEnvironmentVersionsCreateOrUpdate ... +func (c EnvironmentVersionClient) RegistryEnvironmentVersionsCreateOrUpdate(ctx context.Context, id RegistryEnvironmentVersionId, input EnvironmentVersionResource) (result RegistryEnvironmentVersionsCreateOrUpdateOperationResponse, 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 +} + +// RegistryEnvironmentVersionsCreateOrUpdateThenPoll performs RegistryEnvironmentVersionsCreateOrUpdate then polls until it's completed +func (c EnvironmentVersionClient) RegistryEnvironmentVersionsCreateOrUpdateThenPoll(ctx context.Context, id RegistryEnvironmentVersionId, input EnvironmentVersionResource) error { + result, err := c.RegistryEnvironmentVersionsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RegistryEnvironmentVersionsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegistryEnvironmentVersionsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentversion/method_registryenvironmentversionsdelete.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/method_registryenvironmentversionsdelete.go new file mode 100644 index 00000000000..a07477e8d50 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/method_registryenvironmentversionsdelete.go @@ -0,0 +1,71 @@ +package environmentversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryEnvironmentVersionsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RegistryEnvironmentVersionsDelete ... +func (c EnvironmentVersionClient) RegistryEnvironmentVersionsDelete(ctx context.Context, id RegistryEnvironmentVersionId) (result RegistryEnvironmentVersionsDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RegistryEnvironmentVersionsDeleteThenPoll performs RegistryEnvironmentVersionsDelete then polls until it's completed +func (c EnvironmentVersionClient) RegistryEnvironmentVersionsDeleteThenPoll(ctx context.Context, id RegistryEnvironmentVersionId) error { + result, err := c.RegistryEnvironmentVersionsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing RegistryEnvironmentVersionsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegistryEnvironmentVersionsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentversion/method_registryenvironmentversionsget.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/method_registryenvironmentversionsget.go new file mode 100644 index 00000000000..bb40fdc6ebc --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/method_registryenvironmentversionsget.go @@ -0,0 +1,53 @@ +package environmentversion + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryEnvironmentVersionsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *EnvironmentVersionResource +} + +// RegistryEnvironmentVersionsGet ... +func (c EnvironmentVersionClient) RegistryEnvironmentVersionsGet(ctx context.Context, id RegistryEnvironmentVersionId) (result RegistryEnvironmentVersionsGetOperationResponse, 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 EnvironmentVersionResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentversion/method_registryenvironmentversionslist.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/method_registryenvironmentversionslist.go new file mode 100644 index 00000000000..15d1285660a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/method_registryenvironmentversionslist.go @@ -0,0 +1,146 @@ +package environmentversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryEnvironmentVersionsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]EnvironmentVersionResource +} + +type RegistryEnvironmentVersionsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []EnvironmentVersionResource +} + +type RegistryEnvironmentVersionsListOperationOptions struct { + ListViewType *ListViewType + OrderBy *string + Skip *string + Top *int64 +} + +func DefaultRegistryEnvironmentVersionsListOperationOptions() RegistryEnvironmentVersionsListOperationOptions { + return RegistryEnvironmentVersionsListOperationOptions{} +} + +func (o RegistryEnvironmentVersionsListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RegistryEnvironmentVersionsListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RegistryEnvironmentVersionsListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ListViewType != nil { + out.Append("listViewType", fmt.Sprintf("%v", *o.ListViewType)) + } + if o.OrderBy != nil { + out.Append("$orderBy", fmt.Sprintf("%v", *o.OrderBy)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type RegistryEnvironmentVersionsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *RegistryEnvironmentVersionsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// RegistryEnvironmentVersionsList ... +func (c EnvironmentVersionClient) RegistryEnvironmentVersionsList(ctx context.Context, id RegistryEnvironmentId, options RegistryEnvironmentVersionsListOperationOptions) (result RegistryEnvironmentVersionsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &RegistryEnvironmentVersionsListCustomPager{}, + Path: fmt.Sprintf("%s/versions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]EnvironmentVersionResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RegistryEnvironmentVersionsListComplete retrieves all the results into a single object +func (c EnvironmentVersionClient) RegistryEnvironmentVersionsListComplete(ctx context.Context, id RegistryEnvironmentId, options RegistryEnvironmentVersionsListOperationOptions) (RegistryEnvironmentVersionsListCompleteResult, error) { + return c.RegistryEnvironmentVersionsListCompleteMatchingPredicate(ctx, id, options, EnvironmentVersionResourceOperationPredicate{}) +} + +// RegistryEnvironmentVersionsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c EnvironmentVersionClient) RegistryEnvironmentVersionsListCompleteMatchingPredicate(ctx context.Context, id RegistryEnvironmentId, options RegistryEnvironmentVersionsListOperationOptions, predicate EnvironmentVersionResourceOperationPredicate) (result RegistryEnvironmentVersionsListCompleteResult, err error) { + items := make([]EnvironmentVersionResource, 0) + + resp, err := c.RegistryEnvironmentVersionsList(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 = RegistryEnvironmentVersionsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentversion/model_buildcontext.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/model_buildcontext.go new file mode 100644 index 00000000000..76f3414b848 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/model_buildcontext.go @@ -0,0 +1,9 @@ +package environmentversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BuildContext struct { + ContextUri string `json:"contextUri"` + DockerfilePath *string `json:"dockerfilePath,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentversion/model_destinationasset.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/model_destinationasset.go new file mode 100644 index 00000000000..c5123cd9671 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/model_destinationasset.go @@ -0,0 +1,10 @@ +package environmentversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DestinationAsset struct { + DestinationName *string `json:"destinationName,omitempty"` + DestinationVersion *string `json:"destinationVersion,omitempty"` + RegistryName *string `json:"registryName,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentversion/model_environmentversion.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/model_environmentversion.go new file mode 100644 index 00000000000..2ac0ac2a8cd --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/model_environmentversion.go @@ -0,0 +1,21 @@ +package environmentversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnvironmentVersion struct { + AutoRebuild *AutoRebuildSetting `json:"autoRebuild,omitempty"` + Build *BuildContext `json:"build,omitempty"` + CondaFile *string `json:"condaFile,omitempty"` + Description *string `json:"description,omitempty"` + EnvironmentType *EnvironmentType `json:"environmentType,omitempty"` + Image *string `json:"image,omitempty"` + InferenceConfig *InferenceContainerProperties `json:"inferenceConfig,omitempty"` + IsAnonymous *bool `json:"isAnonymous,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + OsType *OperatingSystemType `json:"osType,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ProvisioningState *AssetProvisioningState `json:"provisioningState,omitempty"` + Stage *string `json:"stage,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentversion/model_environmentversionresource.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/model_environmentversionresource.go new file mode 100644 index 00000000000..67b2e6471bd --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/model_environmentversionresource.go @@ -0,0 +1,16 @@ +package environmentversion + +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 EnvironmentVersionResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties EnvironmentVersion `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentversion/model_inferencecontainerproperties.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/model_inferencecontainerproperties.go new file mode 100644 index 00000000000..3322e6f42e3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/model_inferencecontainerproperties.go @@ -0,0 +1,11 @@ +package environmentversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InferenceContainerProperties struct { + LivenessRoute *Route `json:"livenessRoute,omitempty"` + ReadinessRoute *Route `json:"readinessRoute,omitempty"` + ScoringRoute *Route `json:"scoringRoute,omitempty"` + StartupRoute *Route `json:"startupRoute,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentversion/model_route.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/model_route.go new file mode 100644 index 00000000000..0c2b5735082 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/model_route.go @@ -0,0 +1,9 @@ +package environmentversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Route struct { + Path string `json:"path"` + Port int64 `json:"port"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/environmentversion/predicates.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/predicates.go new file mode 100644 index 00000000000..88635632632 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/predicates.go @@ -0,0 +1,27 @@ +package environmentversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnvironmentVersionResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p EnvironmentVersionResourceOperationPredicate) Matches(input EnvironmentVersionResource) 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/machinelearningservices/2025-04-01/environmentversion/version.go b/resource-manager/machinelearningservices/2025-04-01/environmentversion/version.go new file mode 100644 index 00000000000..6c2f782b868 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/environmentversion/version.go @@ -0,0 +1,10 @@ +package environmentversion + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/environmentversion/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/feature/README.md b/resource-manager/machinelearningservices/2025-04-01/feature/README.md new file mode 100644 index 00000000000..4d1fc88c307 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/feature/README.md @@ -0,0 +1,53 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/feature` Documentation + +The `feature` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/feature" +``` + + +### Client Initialization + +```go +client := feature.NewFeatureClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `FeatureClient.Get` + +```go +ctx := context.TODO() +id := feature.NewFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureSetName", "versionName", "featureName") + +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: `FeatureClient.List` + +```go +ctx := context.TODO() +id := feature.NewFeatureSetVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureSetName", "versionName") + +// alternatively `client.List(ctx, id, feature.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, feature.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/feature/client.go b/resource-manager/machinelearningservices/2025-04-01/feature/client.go new file mode 100644 index 00000000000..38863527c69 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/feature/client.go @@ -0,0 +1,26 @@ +package feature + +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 FeatureClient struct { + Client *resourcemanager.Client +} + +func NewFeatureClientWithBaseURI(sdkApi sdkEnv.Api) (*FeatureClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "feature", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating FeatureClient: %+v", err) + } + + return &FeatureClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/feature/constants.go b/resource-manager/machinelearningservices/2025-04-01/feature/constants.go new file mode 100644 index 00000000000..15be88de147 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/feature/constants.go @@ -0,0 +1,113 @@ +package feature + +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 FeatureDataType string + +const ( + FeatureDataTypeBinary FeatureDataType = "Binary" + FeatureDataTypeBoolean FeatureDataType = "Boolean" + FeatureDataTypeDatetime FeatureDataType = "Datetime" + FeatureDataTypeDouble FeatureDataType = "Double" + FeatureDataTypeFloat FeatureDataType = "Float" + FeatureDataTypeInteger FeatureDataType = "Integer" + FeatureDataTypeLong FeatureDataType = "Long" + FeatureDataTypeString FeatureDataType = "String" +) + +func PossibleValuesForFeatureDataType() []string { + return []string{ + string(FeatureDataTypeBinary), + string(FeatureDataTypeBoolean), + string(FeatureDataTypeDatetime), + string(FeatureDataTypeDouble), + string(FeatureDataTypeFloat), + string(FeatureDataTypeInteger), + string(FeatureDataTypeLong), + string(FeatureDataTypeString), + } +} + +func (s *FeatureDataType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFeatureDataType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFeatureDataType(input string) (*FeatureDataType, error) { + vals := map[string]FeatureDataType{ + "binary": FeatureDataTypeBinary, + "boolean": FeatureDataTypeBoolean, + "datetime": FeatureDataTypeDatetime, + "double": FeatureDataTypeDouble, + "float": FeatureDataTypeFloat, + "integer": FeatureDataTypeInteger, + "long": FeatureDataTypeLong, + "string": FeatureDataTypeString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FeatureDataType(input) + return &out, nil +} + +type ListViewType string + +const ( + ListViewTypeActiveOnly ListViewType = "ActiveOnly" + ListViewTypeAll ListViewType = "All" + ListViewTypeArchivedOnly ListViewType = "ArchivedOnly" +) + +func PossibleValuesForListViewType() []string { + return []string{ + string(ListViewTypeActiveOnly), + string(ListViewTypeAll), + string(ListViewTypeArchivedOnly), + } +} + +func (s *ListViewType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseListViewType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseListViewType(input string) (*ListViewType, error) { + vals := map[string]ListViewType{ + "activeonly": ListViewTypeActiveOnly, + "all": ListViewTypeAll, + "archivedonly": ListViewTypeArchivedOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ListViewType(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/feature/id_feature.go b/resource-manager/machinelearningservices/2025-04-01/feature/id_feature.go new file mode 100644 index 00000000000..b3fda6a17a7 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/feature/id_feature.go @@ -0,0 +1,157 @@ +package feature + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&FeatureId{}) +} + +var _ resourceids.ResourceId = &FeatureId{} + +// FeatureId is a struct representing the Resource ID for a Feature +type FeatureId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + FeatureSetName string + VersionName string + FeatureName string +} + +// NewFeatureID returns a new FeatureId struct +func NewFeatureID(subscriptionId string, resourceGroupName string, workspaceName string, featureSetName string, versionName string, featureName string) FeatureId { + return FeatureId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + FeatureSetName: featureSetName, + VersionName: versionName, + FeatureName: featureName, + } +} + +// ParseFeatureID parses 'input' into a FeatureId +func ParseFeatureID(input string) (*FeatureId, error) { + parser := resourceids.NewParserFromResourceIdType(&FeatureId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FeatureId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFeatureIDInsensitively parses 'input' case-insensitively into a FeatureId +// note: this method should only be used for API response data and not user input +func ParseFeatureIDInsensitively(input string) (*FeatureId, error) { + parser := resourceids.NewParserFromResourceIdType(&FeatureId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FeatureId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FeatureId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.FeatureSetName, ok = input.Parsed["featureSetName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "featureSetName", input) + } + + if id.VersionName, ok = input.Parsed["versionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "versionName", input) + } + + if id.FeatureName, ok = input.Parsed["featureName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "featureName", input) + } + + return nil +} + +// ValidateFeatureID checks that 'input' can be parsed as a Feature ID +func ValidateFeatureID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseFeatureID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Feature ID +func (id FeatureId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/featureSets/%s/versions/%s/features/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.FeatureSetName, id.VersionName, id.FeatureName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Feature ID +func (id FeatureId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticFeatureSets", "featureSets", "featureSets"), + resourceids.UserSpecifiedSegment("featureSetName", "featureSetName"), + resourceids.StaticSegment("staticVersions", "versions", "versions"), + resourceids.UserSpecifiedSegment("versionName", "versionName"), + resourceids.StaticSegment("staticFeatures", "features", "features"), + resourceids.UserSpecifiedSegment("featureName", "featureName"), + } +} + +// String returns a human-readable description of this Feature ID +func (id FeatureId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Feature Set Name: %q", id.FeatureSetName), + fmt.Sprintf("Version Name: %q", id.VersionName), + fmt.Sprintf("Feature Name: %q", id.FeatureName), + } + return fmt.Sprintf("Feature (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/feature/id_feature_test.go b/resource-manager/machinelearningservices/2025-04-01/feature/id_feature_test.go new file mode 100644 index 00000000000..f5430de3a64 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/feature/id_feature_test.go @@ -0,0 +1,417 @@ +package feature + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &FeatureId{} + +func TestNewFeatureID(t *testing.T) { + id := NewFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureSetName", "versionName", "featureName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.FeatureSetName != "featureSetName" { + t.Fatalf("Expected %q but got %q for Segment 'FeatureSetName'", id.FeatureSetName, "featureSetName") + } + + if id.VersionName != "versionName" { + t.Fatalf("Expected %q but got %q for Segment 'VersionName'", id.VersionName, "versionName") + } + + if id.FeatureName != "featureName" { + t.Fatalf("Expected %q but got %q for Segment 'FeatureName'", id.FeatureName, "featureName") + } +} + +func TestFormatFeatureID(t *testing.T) { + actual := NewFeatureID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureSetName", "versionName", "featureName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/versions/versionName/features/featureName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFeatureID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FeatureId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/versions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/versions/versionName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/versions/versionName/features", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/versions/versionName/features/featureName", + Expected: &FeatureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + FeatureSetName: "featureSetName", + VersionName: "versionName", + FeatureName: "featureName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/versions/versionName/features/featureName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFeatureID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.FeatureSetName != v.Expected.FeatureSetName { + t.Fatalf("Expected %q but got %q for FeatureSetName", v.Expected.FeatureSetName, actual.FeatureSetName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + if actual.FeatureName != v.Expected.FeatureName { + t.Fatalf("Expected %q but got %q for FeatureName", v.Expected.FeatureName, actual.FeatureName) + } + + } +} + +func TestParseFeatureIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FeatureId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReSeTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReSeTs/fEaTuReSeTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/versions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReSeTs/fEaTuReSeTnAmE/vErSiOnS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/versions/versionName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReSeTs/fEaTuReSeTnAmE/vErSiOnS/vErSiOnNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/versions/versionName/features", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReSeTs/fEaTuReSeTnAmE/vErSiOnS/vErSiOnNaMe/fEaTuReS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/versions/versionName/features/featureName", + Expected: &FeatureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + FeatureSetName: "featureSetName", + VersionName: "versionName", + FeatureName: "featureName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/versions/versionName/features/featureName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReSeTs/fEaTuReSeTnAmE/vErSiOnS/vErSiOnNaMe/fEaTuReS/fEaTuReNaMe", + Expected: &FeatureId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + FeatureSetName: "fEaTuReSeTnAmE", + VersionName: "vErSiOnNaMe", + FeatureName: "fEaTuReNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReSeTs/fEaTuReSeTnAmE/vErSiOnS/vErSiOnNaMe/fEaTuReS/fEaTuReNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFeatureIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.FeatureSetName != v.Expected.FeatureSetName { + t.Fatalf("Expected %q but got %q for FeatureSetName", v.Expected.FeatureSetName, actual.FeatureSetName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + if actual.FeatureName != v.Expected.FeatureName { + t.Fatalf("Expected %q but got %q for FeatureName", v.Expected.FeatureName, actual.FeatureName) + } + + } +} + +func TestSegmentsForFeatureId(t *testing.T) { + segments := FeatureId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FeatureId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/feature/id_featuresetversion.go b/resource-manager/machinelearningservices/2025-04-01/feature/id_featuresetversion.go new file mode 100644 index 00000000000..37f9435f851 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/feature/id_featuresetversion.go @@ -0,0 +1,148 @@ +package feature + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&FeatureSetVersionId{}) +} + +var _ resourceids.ResourceId = &FeatureSetVersionId{} + +// FeatureSetVersionId is a struct representing the Resource ID for a Feature Set Version +type FeatureSetVersionId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + FeatureSetName string + VersionName string +} + +// NewFeatureSetVersionID returns a new FeatureSetVersionId struct +func NewFeatureSetVersionID(subscriptionId string, resourceGroupName string, workspaceName string, featureSetName string, versionName string) FeatureSetVersionId { + return FeatureSetVersionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + FeatureSetName: featureSetName, + VersionName: versionName, + } +} + +// ParseFeatureSetVersionID parses 'input' into a FeatureSetVersionId +func ParseFeatureSetVersionID(input string) (*FeatureSetVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&FeatureSetVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FeatureSetVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFeatureSetVersionIDInsensitively parses 'input' case-insensitively into a FeatureSetVersionId +// note: this method should only be used for API response data and not user input +func ParseFeatureSetVersionIDInsensitively(input string) (*FeatureSetVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&FeatureSetVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FeatureSetVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FeatureSetVersionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.FeatureSetName, ok = input.Parsed["featureSetName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "featureSetName", input) + } + + if id.VersionName, ok = input.Parsed["versionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "versionName", input) + } + + return nil +} + +// ValidateFeatureSetVersionID checks that 'input' can be parsed as a Feature Set Version ID +func ValidateFeatureSetVersionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseFeatureSetVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Feature Set Version ID +func (id FeatureSetVersionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/featureSets/%s/versions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.FeatureSetName, id.VersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Feature Set Version ID +func (id FeatureSetVersionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticFeatureSets", "featureSets", "featureSets"), + resourceids.UserSpecifiedSegment("featureSetName", "featureSetName"), + resourceids.StaticSegment("staticVersions", "versions", "versions"), + resourceids.UserSpecifiedSegment("versionName", "versionName"), + } +} + +// String returns a human-readable description of this Feature Set Version ID +func (id FeatureSetVersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Feature Set Name: %q", id.FeatureSetName), + fmt.Sprintf("Version Name: %q", id.VersionName), + } + return fmt.Sprintf("Feature Set Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/feature/id_featuresetversion_test.go b/resource-manager/machinelearningservices/2025-04-01/feature/id_featuresetversion_test.go new file mode 100644 index 00000000000..d52eb59e90e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/feature/id_featuresetversion_test.go @@ -0,0 +1,372 @@ +package feature + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &FeatureSetVersionId{} + +func TestNewFeatureSetVersionID(t *testing.T) { + id := NewFeatureSetVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureSetName", "versionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.FeatureSetName != "featureSetName" { + t.Fatalf("Expected %q but got %q for Segment 'FeatureSetName'", id.FeatureSetName, "featureSetName") + } + + if id.VersionName != "versionName" { + t.Fatalf("Expected %q but got %q for Segment 'VersionName'", id.VersionName, "versionName") + } +} + +func TestFormatFeatureSetVersionID(t *testing.T) { + actual := NewFeatureSetVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureSetName", "versionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/versions/versionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFeatureSetVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FeatureSetVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/versions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/versions/versionName", + Expected: &FeatureSetVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + FeatureSetName: "featureSetName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/versions/versionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFeatureSetVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.FeatureSetName != v.Expected.FeatureSetName { + t.Fatalf("Expected %q but got %q for FeatureSetName", v.Expected.FeatureSetName, actual.FeatureSetName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestParseFeatureSetVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FeatureSetVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReSeTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReSeTs/fEaTuReSeTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/versions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReSeTs/fEaTuReSeTnAmE/vErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/versions/versionName", + Expected: &FeatureSetVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + FeatureSetName: "featureSetName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/versions/versionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReSeTs/fEaTuReSeTnAmE/vErSiOnS/vErSiOnNaMe", + Expected: &FeatureSetVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + FeatureSetName: "fEaTuReSeTnAmE", + VersionName: "vErSiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReSeTs/fEaTuReSeTnAmE/vErSiOnS/vErSiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFeatureSetVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.FeatureSetName != v.Expected.FeatureSetName { + t.Fatalf("Expected %q but got %q for FeatureSetName", v.Expected.FeatureSetName, actual.FeatureSetName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestSegmentsForFeatureSetVersionId(t *testing.T) { + segments := FeatureSetVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FeatureSetVersionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/feature/method_get.go b/resource-manager/machinelearningservices/2025-04-01/feature/method_get.go new file mode 100644 index 00000000000..2a3e74ccdaf --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/feature/method_get.go @@ -0,0 +1,53 @@ +package feature + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *FeatureResource +} + +// Get ... +func (c FeatureClient) Get(ctx context.Context, id FeatureId) (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 FeatureResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/feature/method_list.go b/resource-manager/machinelearningservices/2025-04-01/feature/method_list.go new file mode 100644 index 00000000000..9ba39db8672 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/feature/method_list.go @@ -0,0 +1,154 @@ +package feature + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]FeatureResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []FeatureResource +} + +type ListOperationOptions struct { + Description *string + FeatureName *string + ListViewType *ListViewType + PageSize *int64 + Skip *string + Tags *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.Description != nil { + out.Append("description", fmt.Sprintf("%v", *o.Description)) + } + if o.FeatureName != nil { + out.Append("featureName", fmt.Sprintf("%v", *o.FeatureName)) + } + if o.ListViewType != nil { + out.Append("listViewType", fmt.Sprintf("%v", *o.ListViewType)) + } + if o.PageSize != nil { + out.Append("pageSize", fmt.Sprintf("%v", *o.PageSize)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Tags != nil { + out.Append("tags", fmt.Sprintf("%v", *o.Tags)) + } + 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 FeatureClient) List(ctx context.Context, id FeatureSetVersionId, 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/features", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]FeatureResource `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 FeatureClient) ListComplete(ctx context.Context, id FeatureSetVersionId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, FeatureResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c FeatureClient) ListCompleteMatchingPredicate(ctx context.Context, id FeatureSetVersionId, options ListOperationOptions, predicate FeatureResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]FeatureResource, 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/machinelearningservices/2025-04-01/feature/model_feature.go b/resource-manager/machinelearningservices/2025-04-01/feature/model_feature.go new file mode 100644 index 00000000000..ed8809ae8d4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/feature/model_feature.go @@ -0,0 +1,12 @@ +package feature + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Feature struct { + DataType *FeatureDataType `json:"dataType,omitempty"` + Description *string `json:"description,omitempty"` + FeatureName *string `json:"featureName,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/feature/model_featureresource.go b/resource-manager/machinelearningservices/2025-04-01/feature/model_featureresource.go new file mode 100644 index 00000000000..966ad578b66 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/feature/model_featureresource.go @@ -0,0 +1,16 @@ +package feature + +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 FeatureResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties Feature `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/feature/predicates.go b/resource-manager/machinelearningservices/2025-04-01/feature/predicates.go new file mode 100644 index 00000000000..2463781d78d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/feature/predicates.go @@ -0,0 +1,27 @@ +package feature + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FeatureResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p FeatureResourceOperationPredicate) Matches(input FeatureResource) 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/machinelearningservices/2025-04-01/feature/version.go b/resource-manager/machinelearningservices/2025-04-01/feature/version.go new file mode 100644 index 00000000000..2bec86717b8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/feature/version.go @@ -0,0 +1,10 @@ +package feature + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/feature/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/README.md b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/README.md new file mode 100644 index 00000000000..fdeef7e7816 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer` Documentation + +The `featuresetcontainer` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer" +``` + + +### Client Initialization + +```go +client := featuresetcontainer.NewFeaturesetContainerClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `FeaturesetContainerClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := featuresetcontainer.NewFeatureSetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureSetName") + +payload := featuresetcontainer.FeaturesetContainerResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `FeaturesetContainerClient.Delete` + +```go +ctx := context.TODO() +id := featuresetcontainer.NewFeatureSetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureSetName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `FeaturesetContainerClient.GetEntity` + +```go +ctx := context.TODO() +id := featuresetcontainer.NewFeatureSetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureSetName") + +read, err := client.GetEntity(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `FeaturesetContainerClient.List` + +```go +ctx := context.TODO() +id := featuresetcontainer.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +// alternatively `client.List(ctx, id, featuresetcontainer.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, featuresetcontainer.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/client.go b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/client.go new file mode 100644 index 00000000000..137b30b74d2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/client.go @@ -0,0 +1,26 @@ +package featuresetcontainer + +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 FeaturesetContainerClient struct { + Client *resourcemanager.Client +} + +func NewFeaturesetContainerClientWithBaseURI(sdkApi sdkEnv.Api) (*FeaturesetContainerClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "featuresetcontainer", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating FeaturesetContainerClient: %+v", err) + } + + return &FeaturesetContainerClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/constants.go b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/constants.go new file mode 100644 index 00000000000..6444d1c6944 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/constants.go @@ -0,0 +1,107 @@ +package featuresetcontainer + +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 AssetProvisioningState string + +const ( + AssetProvisioningStateCanceled AssetProvisioningState = "Canceled" + AssetProvisioningStateCreating AssetProvisioningState = "Creating" + AssetProvisioningStateDeleting AssetProvisioningState = "Deleting" + AssetProvisioningStateFailed AssetProvisioningState = "Failed" + AssetProvisioningStateSucceeded AssetProvisioningState = "Succeeded" + AssetProvisioningStateUpdating AssetProvisioningState = "Updating" +) + +func PossibleValuesForAssetProvisioningState() []string { + return []string{ + string(AssetProvisioningStateCanceled), + string(AssetProvisioningStateCreating), + string(AssetProvisioningStateDeleting), + string(AssetProvisioningStateFailed), + string(AssetProvisioningStateSucceeded), + string(AssetProvisioningStateUpdating), + } +} + +func (s *AssetProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAssetProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAssetProvisioningState(input string) (*AssetProvisioningState, error) { + vals := map[string]AssetProvisioningState{ + "canceled": AssetProvisioningStateCanceled, + "creating": AssetProvisioningStateCreating, + "deleting": AssetProvisioningStateDeleting, + "failed": AssetProvisioningStateFailed, + "succeeded": AssetProvisioningStateSucceeded, + "updating": AssetProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AssetProvisioningState(input) + return &out, nil +} + +type ListViewType string + +const ( + ListViewTypeActiveOnly ListViewType = "ActiveOnly" + ListViewTypeAll ListViewType = "All" + ListViewTypeArchivedOnly ListViewType = "ArchivedOnly" +) + +func PossibleValuesForListViewType() []string { + return []string{ + string(ListViewTypeActiveOnly), + string(ListViewTypeAll), + string(ListViewTypeArchivedOnly), + } +} + +func (s *ListViewType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseListViewType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseListViewType(input string) (*ListViewType, error) { + vals := map[string]ListViewType{ + "activeonly": ListViewTypeActiveOnly, + "all": ListViewTypeAll, + "archivedonly": ListViewTypeArchivedOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ListViewType(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/id_featureset.go b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/id_featureset.go new file mode 100644 index 00000000000..9bee8c98789 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/id_featureset.go @@ -0,0 +1,139 @@ +package featuresetcontainer + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&FeatureSetId{}) +} + +var _ resourceids.ResourceId = &FeatureSetId{} + +// FeatureSetId is a struct representing the Resource ID for a Feature Set +type FeatureSetId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + FeatureSetName string +} + +// NewFeatureSetID returns a new FeatureSetId struct +func NewFeatureSetID(subscriptionId string, resourceGroupName string, workspaceName string, featureSetName string) FeatureSetId { + return FeatureSetId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + FeatureSetName: featureSetName, + } +} + +// ParseFeatureSetID parses 'input' into a FeatureSetId +func ParseFeatureSetID(input string) (*FeatureSetId, error) { + parser := resourceids.NewParserFromResourceIdType(&FeatureSetId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FeatureSetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFeatureSetIDInsensitively parses 'input' case-insensitively into a FeatureSetId +// note: this method should only be used for API response data and not user input +func ParseFeatureSetIDInsensitively(input string) (*FeatureSetId, error) { + parser := resourceids.NewParserFromResourceIdType(&FeatureSetId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FeatureSetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FeatureSetId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.FeatureSetName, ok = input.Parsed["featureSetName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "featureSetName", input) + } + + return nil +} + +// ValidateFeatureSetID checks that 'input' can be parsed as a Feature Set ID +func ValidateFeatureSetID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseFeatureSetID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Feature Set ID +func (id FeatureSetId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/featureSets/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.FeatureSetName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Feature Set ID +func (id FeatureSetId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticFeatureSets", "featureSets", "featureSets"), + resourceids.UserSpecifiedSegment("featureSetName", "featureSetName"), + } +} + +// String returns a human-readable description of this Feature Set ID +func (id FeatureSetId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Feature Set Name: %q", id.FeatureSetName), + } + return fmt.Sprintf("Feature Set (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/id_featureset_test.go b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/id_featureset_test.go new file mode 100644 index 00000000000..1f9ab1ad79c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/id_featureset_test.go @@ -0,0 +1,327 @@ +package featuresetcontainer + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &FeatureSetId{} + +func TestNewFeatureSetID(t *testing.T) { + id := NewFeatureSetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureSetName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.FeatureSetName != "featureSetName" { + t.Fatalf("Expected %q but got %q for Segment 'FeatureSetName'", id.FeatureSetName, "featureSetName") + } +} + +func TestFormatFeatureSetID(t *testing.T) { + actual := NewFeatureSetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureSetName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFeatureSetID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FeatureSetId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName", + Expected: &FeatureSetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + FeatureSetName: "featureSetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFeatureSetID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.FeatureSetName != v.Expected.FeatureSetName { + t.Fatalf("Expected %q but got %q for FeatureSetName", v.Expected.FeatureSetName, actual.FeatureSetName) + } + + } +} + +func TestParseFeatureSetIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FeatureSetId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReSeTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName", + Expected: &FeatureSetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + FeatureSetName: "featureSetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReSeTs/fEaTuReSeTnAmE", + Expected: &FeatureSetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + FeatureSetName: "fEaTuReSeTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReSeTs/fEaTuReSeTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFeatureSetIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.FeatureSetName != v.Expected.FeatureSetName { + t.Fatalf("Expected %q but got %q for FeatureSetName", v.Expected.FeatureSetName, actual.FeatureSetName) + } + + } +} + +func TestSegmentsForFeatureSetId(t *testing.T) { + segments := FeatureSetId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FeatureSetId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/id_workspace.go b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/id_workspace.go new file mode 100644 index 00000000000..ee6e396f1a3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/id_workspace.go @@ -0,0 +1,130 @@ +package featuresetcontainer + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/id_workspace_test.go b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/id_workspace_test.go new file mode 100644 index 00000000000..588da686304 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/id_workspace_test.go @@ -0,0 +1,282 @@ +package featuresetcontainer + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/method_createorupdate.go b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/method_createorupdate.go new file mode 100644 index 00000000000..cbef6f64207 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/method_createorupdate.go @@ -0,0 +1,75 @@ +package featuresetcontainer + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *FeaturesetContainerResource +} + +// CreateOrUpdate ... +func (c FeaturesetContainerClient) CreateOrUpdate(ctx context.Context, id FeatureSetId, input FeaturesetContainerResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c FeaturesetContainerClient) CreateOrUpdateThenPoll(ctx context.Context, id FeatureSetId, input FeaturesetContainerResource) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/method_delete.go b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/method_delete.go new file mode 100644 index 00000000000..d5b2cb9c5b8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/method_delete.go @@ -0,0 +1,71 @@ +package featuresetcontainer + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 FeaturesetContainerClient) Delete(ctx context.Context, id FeatureSetId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c FeaturesetContainerClient) DeleteThenPoll(ctx context.Context, id FeatureSetId) 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/machinelearningservices/2025-04-01/featuresetcontainer/method_getentity.go b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/method_getentity.go new file mode 100644 index 00000000000..8632557b0bb --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/method_getentity.go @@ -0,0 +1,53 @@ +package featuresetcontainer + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetEntityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FeaturesetContainerResource +} + +// GetEntity ... +func (c FeaturesetContainerClient) GetEntity(ctx context.Context, id FeatureSetId) (result GetEntityOperationResponse, 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 FeaturesetContainerResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/method_list.go b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/method_list.go new file mode 100644 index 00000000000..c969714237f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/method_list.go @@ -0,0 +1,158 @@ +package featuresetcontainer + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]FeaturesetContainerResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []FeaturesetContainerResource +} + +type ListOperationOptions struct { + CreatedBy *string + Description *string + ListViewType *ListViewType + Name *string + PageSize *int64 + Skip *string + Tags *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.CreatedBy != nil { + out.Append("createdBy", fmt.Sprintf("%v", *o.CreatedBy)) + } + if o.Description != nil { + out.Append("description", fmt.Sprintf("%v", *o.Description)) + } + if o.ListViewType != nil { + out.Append("listViewType", fmt.Sprintf("%v", *o.ListViewType)) + } + if o.Name != nil { + out.Append("name", fmt.Sprintf("%v", *o.Name)) + } + if o.PageSize != nil { + out.Append("pageSize", fmt.Sprintf("%v", *o.PageSize)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Tags != nil { + out.Append("tags", fmt.Sprintf("%v", *o.Tags)) + } + 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 FeaturesetContainerClient) List(ctx context.Context, id WorkspaceId, 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/featureSets", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]FeaturesetContainerResource `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 FeaturesetContainerClient) ListComplete(ctx context.Context, id WorkspaceId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, FeaturesetContainerResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c FeaturesetContainerClient) ListCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, options ListOperationOptions, predicate FeaturesetContainerResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]FeaturesetContainerResource, 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/machinelearningservices/2025-04-01/featuresetcontainer/model_featuresetcontainer.go b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/model_featuresetcontainer.go new file mode 100644 index 00000000000..b4abf55d6ea --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/model_featuresetcontainer.go @@ -0,0 +1,14 @@ +package featuresetcontainer + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FeaturesetContainer struct { + Description *string `json:"description,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + LatestVersion *string `json:"latestVersion,omitempty"` + NextVersion *string `json:"nextVersion,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ProvisioningState *AssetProvisioningState `json:"provisioningState,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/model_featuresetcontainerresource.go b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/model_featuresetcontainerresource.go new file mode 100644 index 00000000000..613e7b2ee4c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/model_featuresetcontainerresource.go @@ -0,0 +1,16 @@ +package featuresetcontainer + +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 FeaturesetContainerResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties FeaturesetContainer `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/predicates.go b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/predicates.go new file mode 100644 index 00000000000..e6b9b9c64c5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/predicates.go @@ -0,0 +1,27 @@ +package featuresetcontainer + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FeaturesetContainerResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p FeaturesetContainerResourceOperationPredicate) Matches(input FeaturesetContainerResource) 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/machinelearningservices/2025-04-01/featuresetcontainer/version.go b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/version.go new file mode 100644 index 00000000000..2765806fb32 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetcontainer/version.go @@ -0,0 +1,10 @@ +package featuresetcontainer + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/featuresetcontainer/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetversion/README.md b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/README.md new file mode 100644 index 00000000000..76e15f9cf8d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/README.md @@ -0,0 +1,99 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/featuresetversion` Documentation + +The `featuresetversion` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/featuresetversion" +``` + + +### Client Initialization + +```go +client := featuresetversion.NewFeaturesetVersionClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `FeaturesetVersionClient.Backfill` + +```go +ctx := context.TODO() +id := featuresetversion.NewFeatureSetVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureSetName", "versionName") + +payload := featuresetversion.FeaturesetVersionBackfillRequest{ + // ... +} + + +if err := client.BackfillThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `FeaturesetVersionClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := featuresetversion.NewFeatureSetVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureSetName", "versionName") + +payload := featuresetversion.FeaturesetVersionResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `FeaturesetVersionClient.Delete` + +```go +ctx := context.TODO() +id := featuresetversion.NewFeatureSetVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureSetName", "versionName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `FeaturesetVersionClient.Get` + +```go +ctx := context.TODO() +id := featuresetversion.NewFeatureSetVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureSetName", "versionName") + +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: `FeaturesetVersionClient.List` + +```go +ctx := context.TODO() +id := featuresetversion.NewFeatureSetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureSetName") + +// alternatively `client.List(ctx, id, featuresetversion.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, featuresetversion.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetversion/client.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/client.go new file mode 100644 index 00000000000..d7b0f6856aa --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/client.go @@ -0,0 +1,26 @@ +package featuresetversion + +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 FeaturesetVersionClient struct { + Client *resourcemanager.Client +} + +func NewFeaturesetVersionClientWithBaseURI(sdkApi sdkEnv.Api) (*FeaturesetVersionClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "featuresetversion", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating FeaturesetVersionClient: %+v", err) + } + + return &FeaturesetVersionClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetversion/constants.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/constants.go new file mode 100644 index 00000000000..27b9f13529f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/constants.go @@ -0,0 +1,430 @@ +package featuresetversion + +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 AssetProvisioningState string + +const ( + AssetProvisioningStateCanceled AssetProvisioningState = "Canceled" + AssetProvisioningStateCreating AssetProvisioningState = "Creating" + AssetProvisioningStateDeleting AssetProvisioningState = "Deleting" + AssetProvisioningStateFailed AssetProvisioningState = "Failed" + AssetProvisioningStateSucceeded AssetProvisioningState = "Succeeded" + AssetProvisioningStateUpdating AssetProvisioningState = "Updating" +) + +func PossibleValuesForAssetProvisioningState() []string { + return []string{ + string(AssetProvisioningStateCanceled), + string(AssetProvisioningStateCreating), + string(AssetProvisioningStateDeleting), + string(AssetProvisioningStateFailed), + string(AssetProvisioningStateSucceeded), + string(AssetProvisioningStateUpdating), + } +} + +func (s *AssetProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAssetProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAssetProvisioningState(input string) (*AssetProvisioningState, error) { + vals := map[string]AssetProvisioningState{ + "canceled": AssetProvisioningStateCanceled, + "creating": AssetProvisioningStateCreating, + "deleting": AssetProvisioningStateDeleting, + "failed": AssetProvisioningStateFailed, + "succeeded": AssetProvisioningStateSucceeded, + "updating": AssetProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AssetProvisioningState(input) + return &out, nil +} + +type DataAvailabilityStatus string + +const ( + DataAvailabilityStatusComplete DataAvailabilityStatus = "Complete" + DataAvailabilityStatusIncomplete DataAvailabilityStatus = "Incomplete" + DataAvailabilityStatusNone DataAvailabilityStatus = "None" + DataAvailabilityStatusPending DataAvailabilityStatus = "Pending" +) + +func PossibleValuesForDataAvailabilityStatus() []string { + return []string{ + string(DataAvailabilityStatusComplete), + string(DataAvailabilityStatusIncomplete), + string(DataAvailabilityStatusNone), + string(DataAvailabilityStatusPending), + } +} + +func (s *DataAvailabilityStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataAvailabilityStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataAvailabilityStatus(input string) (*DataAvailabilityStatus, error) { + vals := map[string]DataAvailabilityStatus{ + "complete": DataAvailabilityStatusComplete, + "incomplete": DataAvailabilityStatusIncomplete, + "none": DataAvailabilityStatusNone, + "pending": DataAvailabilityStatusPending, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataAvailabilityStatus(input) + return &out, nil +} + +type EmailNotificationEnableType string + +const ( + EmailNotificationEnableTypeJobCancelled EmailNotificationEnableType = "JobCancelled" + EmailNotificationEnableTypeJobCompleted EmailNotificationEnableType = "JobCompleted" + EmailNotificationEnableTypeJobFailed EmailNotificationEnableType = "JobFailed" +) + +func PossibleValuesForEmailNotificationEnableType() []string { + return []string{ + string(EmailNotificationEnableTypeJobCancelled), + string(EmailNotificationEnableTypeJobCompleted), + string(EmailNotificationEnableTypeJobFailed), + } +} + +func (s *EmailNotificationEnableType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEmailNotificationEnableType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEmailNotificationEnableType(input string) (*EmailNotificationEnableType, error) { + vals := map[string]EmailNotificationEnableType{ + "jobcancelled": EmailNotificationEnableTypeJobCancelled, + "jobcompleted": EmailNotificationEnableTypeJobCompleted, + "jobfailed": EmailNotificationEnableTypeJobFailed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EmailNotificationEnableType(input) + return &out, nil +} + +type ListViewType string + +const ( + ListViewTypeActiveOnly ListViewType = "ActiveOnly" + ListViewTypeAll ListViewType = "All" + ListViewTypeArchivedOnly ListViewType = "ArchivedOnly" +) + +func PossibleValuesForListViewType() []string { + return []string{ + string(ListViewTypeActiveOnly), + string(ListViewTypeAll), + string(ListViewTypeArchivedOnly), + } +} + +func (s *ListViewType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseListViewType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseListViewType(input string) (*ListViewType, error) { + vals := map[string]ListViewType{ + "activeonly": ListViewTypeActiveOnly, + "all": ListViewTypeAll, + "archivedonly": ListViewTypeArchivedOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ListViewType(input) + return &out, nil +} + +type MaterializationStoreType string + +const ( + MaterializationStoreTypeNone MaterializationStoreType = "None" + MaterializationStoreTypeOffline MaterializationStoreType = "Offline" + MaterializationStoreTypeOnline MaterializationStoreType = "Online" + MaterializationStoreTypeOnlineAndOffline MaterializationStoreType = "OnlineAndOffline" +) + +func PossibleValuesForMaterializationStoreType() []string { + return []string{ + string(MaterializationStoreTypeNone), + string(MaterializationStoreTypeOffline), + string(MaterializationStoreTypeOnline), + string(MaterializationStoreTypeOnlineAndOffline), + } +} + +func (s *MaterializationStoreType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMaterializationStoreType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMaterializationStoreType(input string) (*MaterializationStoreType, error) { + vals := map[string]MaterializationStoreType{ + "none": MaterializationStoreTypeNone, + "offline": MaterializationStoreTypeOffline, + "online": MaterializationStoreTypeOnline, + "onlineandoffline": MaterializationStoreTypeOnlineAndOffline, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MaterializationStoreType(input) + return &out, nil +} + +type RecurrenceFrequency string + +const ( + RecurrenceFrequencyDay RecurrenceFrequency = "Day" + RecurrenceFrequencyHour RecurrenceFrequency = "Hour" + RecurrenceFrequencyMinute RecurrenceFrequency = "Minute" + RecurrenceFrequencyMonth RecurrenceFrequency = "Month" + RecurrenceFrequencyWeek RecurrenceFrequency = "Week" +) + +func PossibleValuesForRecurrenceFrequency() []string { + return []string{ + string(RecurrenceFrequencyDay), + string(RecurrenceFrequencyHour), + string(RecurrenceFrequencyMinute), + string(RecurrenceFrequencyMonth), + string(RecurrenceFrequencyWeek), + } +} + +func (s *RecurrenceFrequency) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecurrenceFrequency(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecurrenceFrequency(input string) (*RecurrenceFrequency, error) { + vals := map[string]RecurrenceFrequency{ + "day": RecurrenceFrequencyDay, + "hour": RecurrenceFrequencyHour, + "minute": RecurrenceFrequencyMinute, + "month": RecurrenceFrequencyMonth, + "week": RecurrenceFrequencyWeek, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecurrenceFrequency(input) + return &out, nil +} + +type TriggerType string + +const ( + TriggerTypeCron TriggerType = "Cron" + TriggerTypeRecurrence TriggerType = "Recurrence" +) + +func PossibleValuesForTriggerType() []string { + return []string{ + string(TriggerTypeCron), + string(TriggerTypeRecurrence), + } +} + +func (s *TriggerType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTriggerType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTriggerType(input string) (*TriggerType, error) { + vals := map[string]TriggerType{ + "cron": TriggerTypeCron, + "recurrence": TriggerTypeRecurrence, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TriggerType(input) + return &out, nil +} + +type WebhookType string + +const ( + WebhookTypeAzureDevOps WebhookType = "AzureDevOps" +) + +func PossibleValuesForWebhookType() []string { + return []string{ + string(WebhookTypeAzureDevOps), + } +} + +func (s *WebhookType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWebhookType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWebhookType(input string) (*WebhookType, error) { + vals := map[string]WebhookType{ + "azuredevops": WebhookTypeAzureDevOps, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WebhookType(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/machinelearningservices/2025-04-01/featuresetversion/id_featureset.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/id_featureset.go new file mode 100644 index 00000000000..cd587d73402 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/id_featureset.go @@ -0,0 +1,139 @@ +package featuresetversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&FeatureSetId{}) +} + +var _ resourceids.ResourceId = &FeatureSetId{} + +// FeatureSetId is a struct representing the Resource ID for a Feature Set +type FeatureSetId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + FeatureSetName string +} + +// NewFeatureSetID returns a new FeatureSetId struct +func NewFeatureSetID(subscriptionId string, resourceGroupName string, workspaceName string, featureSetName string) FeatureSetId { + return FeatureSetId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + FeatureSetName: featureSetName, + } +} + +// ParseFeatureSetID parses 'input' into a FeatureSetId +func ParseFeatureSetID(input string) (*FeatureSetId, error) { + parser := resourceids.NewParserFromResourceIdType(&FeatureSetId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FeatureSetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFeatureSetIDInsensitively parses 'input' case-insensitively into a FeatureSetId +// note: this method should only be used for API response data and not user input +func ParseFeatureSetIDInsensitively(input string) (*FeatureSetId, error) { + parser := resourceids.NewParserFromResourceIdType(&FeatureSetId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FeatureSetId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FeatureSetId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.FeatureSetName, ok = input.Parsed["featureSetName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "featureSetName", input) + } + + return nil +} + +// ValidateFeatureSetID checks that 'input' can be parsed as a Feature Set ID +func ValidateFeatureSetID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseFeatureSetID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Feature Set ID +func (id FeatureSetId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/featureSets/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.FeatureSetName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Feature Set ID +func (id FeatureSetId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticFeatureSets", "featureSets", "featureSets"), + resourceids.UserSpecifiedSegment("featureSetName", "featureSetName"), + } +} + +// String returns a human-readable description of this Feature Set ID +func (id FeatureSetId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Feature Set Name: %q", id.FeatureSetName), + } + return fmt.Sprintf("Feature Set (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetversion/id_featureset_test.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/id_featureset_test.go new file mode 100644 index 00000000000..944ba4198f3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/id_featureset_test.go @@ -0,0 +1,327 @@ +package featuresetversion + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &FeatureSetId{} + +func TestNewFeatureSetID(t *testing.T) { + id := NewFeatureSetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureSetName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.FeatureSetName != "featureSetName" { + t.Fatalf("Expected %q but got %q for Segment 'FeatureSetName'", id.FeatureSetName, "featureSetName") + } +} + +func TestFormatFeatureSetID(t *testing.T) { + actual := NewFeatureSetID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureSetName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFeatureSetID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FeatureSetId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName", + Expected: &FeatureSetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + FeatureSetName: "featureSetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFeatureSetID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.FeatureSetName != v.Expected.FeatureSetName { + t.Fatalf("Expected %q but got %q for FeatureSetName", v.Expected.FeatureSetName, actual.FeatureSetName) + } + + } +} + +func TestParseFeatureSetIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FeatureSetId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReSeTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName", + Expected: &FeatureSetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + FeatureSetName: "featureSetName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReSeTs/fEaTuReSeTnAmE", + Expected: &FeatureSetId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + FeatureSetName: "fEaTuReSeTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReSeTs/fEaTuReSeTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFeatureSetIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.FeatureSetName != v.Expected.FeatureSetName { + t.Fatalf("Expected %q but got %q for FeatureSetName", v.Expected.FeatureSetName, actual.FeatureSetName) + } + + } +} + +func TestSegmentsForFeatureSetId(t *testing.T) { + segments := FeatureSetId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FeatureSetId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetversion/id_featuresetversion.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/id_featuresetversion.go new file mode 100644 index 00000000000..5c58da85b49 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/id_featuresetversion.go @@ -0,0 +1,148 @@ +package featuresetversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&FeatureSetVersionId{}) +} + +var _ resourceids.ResourceId = &FeatureSetVersionId{} + +// FeatureSetVersionId is a struct representing the Resource ID for a Feature Set Version +type FeatureSetVersionId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + FeatureSetName string + VersionName string +} + +// NewFeatureSetVersionID returns a new FeatureSetVersionId struct +func NewFeatureSetVersionID(subscriptionId string, resourceGroupName string, workspaceName string, featureSetName string, versionName string) FeatureSetVersionId { + return FeatureSetVersionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + FeatureSetName: featureSetName, + VersionName: versionName, + } +} + +// ParseFeatureSetVersionID parses 'input' into a FeatureSetVersionId +func ParseFeatureSetVersionID(input string) (*FeatureSetVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&FeatureSetVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FeatureSetVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFeatureSetVersionIDInsensitively parses 'input' case-insensitively into a FeatureSetVersionId +// note: this method should only be used for API response data and not user input +func ParseFeatureSetVersionIDInsensitively(input string) (*FeatureSetVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&FeatureSetVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FeatureSetVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FeatureSetVersionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.FeatureSetName, ok = input.Parsed["featureSetName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "featureSetName", input) + } + + if id.VersionName, ok = input.Parsed["versionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "versionName", input) + } + + return nil +} + +// ValidateFeatureSetVersionID checks that 'input' can be parsed as a Feature Set Version ID +func ValidateFeatureSetVersionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseFeatureSetVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Feature Set Version ID +func (id FeatureSetVersionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/featureSets/%s/versions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.FeatureSetName, id.VersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Feature Set Version ID +func (id FeatureSetVersionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticFeatureSets", "featureSets", "featureSets"), + resourceids.UserSpecifiedSegment("featureSetName", "featureSetName"), + resourceids.StaticSegment("staticVersions", "versions", "versions"), + resourceids.UserSpecifiedSegment("versionName", "versionName"), + } +} + +// String returns a human-readable description of this Feature Set Version ID +func (id FeatureSetVersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Feature Set Name: %q", id.FeatureSetName), + fmt.Sprintf("Version Name: %q", id.VersionName), + } + return fmt.Sprintf("Feature Set Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetversion/id_featuresetversion_test.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/id_featuresetversion_test.go new file mode 100644 index 00000000000..f9ca5df75e0 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/id_featuresetversion_test.go @@ -0,0 +1,372 @@ +package featuresetversion + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &FeatureSetVersionId{} + +func TestNewFeatureSetVersionID(t *testing.T) { + id := NewFeatureSetVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureSetName", "versionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.FeatureSetName != "featureSetName" { + t.Fatalf("Expected %q but got %q for Segment 'FeatureSetName'", id.FeatureSetName, "featureSetName") + } + + if id.VersionName != "versionName" { + t.Fatalf("Expected %q but got %q for Segment 'VersionName'", id.VersionName, "versionName") + } +} + +func TestFormatFeatureSetVersionID(t *testing.T) { + actual := NewFeatureSetVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureSetName", "versionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/versions/versionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFeatureSetVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FeatureSetVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/versions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/versions/versionName", + Expected: &FeatureSetVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + FeatureSetName: "featureSetName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/versions/versionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFeatureSetVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.FeatureSetName != v.Expected.FeatureSetName { + t.Fatalf("Expected %q but got %q for FeatureSetName", v.Expected.FeatureSetName, actual.FeatureSetName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestParseFeatureSetVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FeatureSetVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReSeTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReSeTs/fEaTuReSeTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/versions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReSeTs/fEaTuReSeTnAmE/vErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/versions/versionName", + Expected: &FeatureSetVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + FeatureSetName: "featureSetName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureSets/featureSetName/versions/versionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReSeTs/fEaTuReSeTnAmE/vErSiOnS/vErSiOnNaMe", + Expected: &FeatureSetVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + FeatureSetName: "fEaTuReSeTnAmE", + VersionName: "vErSiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReSeTs/fEaTuReSeTnAmE/vErSiOnS/vErSiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFeatureSetVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.FeatureSetName != v.Expected.FeatureSetName { + t.Fatalf("Expected %q but got %q for FeatureSetName", v.Expected.FeatureSetName, actual.FeatureSetName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestSegmentsForFeatureSetVersionId(t *testing.T) { + segments := FeatureSetVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FeatureSetVersionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetversion/method_backfill.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/method_backfill.go new file mode 100644 index 00000000000..32f324e4762 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/method_backfill.go @@ -0,0 +1,75 @@ +package featuresetversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BackfillOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *FeaturesetVersionBackfillResponse +} + +// Backfill ... +func (c FeaturesetVersionClient) Backfill(ctx context.Context, id FeatureSetVersionId, input FeaturesetVersionBackfillRequest) (result BackfillOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/backfill", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// BackfillThenPoll performs Backfill then polls until it's completed +func (c FeaturesetVersionClient) BackfillThenPoll(ctx context.Context, id FeatureSetVersionId, input FeaturesetVersionBackfillRequest) error { + result, err := c.Backfill(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Backfill: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Backfill: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetversion/method_createorupdate.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/method_createorupdate.go new file mode 100644 index 00000000000..9578d6c91aa --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/method_createorupdate.go @@ -0,0 +1,75 @@ +package featuresetversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *FeaturesetVersionResource +} + +// CreateOrUpdate ... +func (c FeaturesetVersionClient) CreateOrUpdate(ctx context.Context, id FeatureSetVersionId, input FeaturesetVersionResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c FeaturesetVersionClient) CreateOrUpdateThenPoll(ctx context.Context, id FeatureSetVersionId, input FeaturesetVersionResource) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetversion/method_delete.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/method_delete.go new file mode 100644 index 00000000000..0b61643761d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/method_delete.go @@ -0,0 +1,71 @@ +package featuresetversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 FeaturesetVersionClient) Delete(ctx context.Context, id FeatureSetVersionId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c FeaturesetVersionClient) DeleteThenPoll(ctx context.Context, id FeatureSetVersionId) 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/machinelearningservices/2025-04-01/featuresetversion/method_get.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/method_get.go new file mode 100644 index 00000000000..4574f92d44a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/method_get.go @@ -0,0 +1,53 @@ +package featuresetversion + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *FeaturesetVersionResource +} + +// Get ... +func (c FeaturesetVersionClient) Get(ctx context.Context, id FeatureSetVersionId) (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 FeaturesetVersionResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetversion/method_list.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/method_list.go new file mode 100644 index 00000000000..17cbb34ecbd --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/method_list.go @@ -0,0 +1,166 @@ +package featuresetversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]FeaturesetVersionResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []FeaturesetVersionResource +} + +type ListOperationOptions struct { + CreatedBy *string + Description *string + ListViewType *ListViewType + PageSize *int64 + Skip *string + Stage *string + Tags *string + Version *string + VersionName *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.CreatedBy != nil { + out.Append("createdBy", fmt.Sprintf("%v", *o.CreatedBy)) + } + if o.Description != nil { + out.Append("description", fmt.Sprintf("%v", *o.Description)) + } + if o.ListViewType != nil { + out.Append("listViewType", fmt.Sprintf("%v", *o.ListViewType)) + } + if o.PageSize != nil { + out.Append("pageSize", fmt.Sprintf("%v", *o.PageSize)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Stage != nil { + out.Append("stage", fmt.Sprintf("%v", *o.Stage)) + } + if o.Tags != nil { + out.Append("tags", fmt.Sprintf("%v", *o.Tags)) + } + if o.Version != nil { + out.Append("version", fmt.Sprintf("%v", *o.Version)) + } + if o.VersionName != nil { + out.Append("versionName", fmt.Sprintf("%v", *o.VersionName)) + } + 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 FeaturesetVersionClient) List(ctx context.Context, id FeatureSetId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/versions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]FeaturesetVersionResource `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 FeaturesetVersionClient) ListComplete(ctx context.Context, id FeatureSetId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, FeaturesetVersionResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c FeaturesetVersionClient) ListCompleteMatchingPredicate(ctx context.Context, id FeatureSetId, options ListOperationOptions, predicate FeaturesetVersionResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]FeaturesetVersionResource, 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/machinelearningservices/2025-04-01/featuresetversion/model_azuredevopswebhook.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_azuredevopswebhook.go new file mode 100644 index 00000000000..ae4bacabe00 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_azuredevopswebhook.go @@ -0,0 +1,51 @@ +package featuresetversion + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Webhook = AzureDevOpsWebhook{} + +type AzureDevOpsWebhook struct { + + // Fields inherited from Webhook + + EventType *string `json:"eventType,omitempty"` + WebhookType WebhookType `json:"webhookType"` +} + +func (s AzureDevOpsWebhook) Webhook() BaseWebhookImpl { + return BaseWebhookImpl{ + EventType: s.EventType, + WebhookType: s.WebhookType, + } +} + +var _ json.Marshaler = AzureDevOpsWebhook{} + +func (s AzureDevOpsWebhook) MarshalJSON() ([]byte, error) { + type wrapper AzureDevOpsWebhook + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureDevOpsWebhook: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureDevOpsWebhook: %+v", err) + } + + decoded["webhookType"] = "AzureDevOps" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureDevOpsWebhook: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_crontrigger.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_crontrigger.go new file mode 100644 index 00000000000..c4628ac394a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_crontrigger.go @@ -0,0 +1,56 @@ +package featuresetversion + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TriggerBase = CronTrigger{} + +type CronTrigger struct { + Expression string `json:"expression"` + + // Fields inherited from TriggerBase + + EndTime *string `json:"endTime,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + TriggerType TriggerType `json:"triggerType"` +} + +func (s CronTrigger) TriggerBase() BaseTriggerBaseImpl { + return BaseTriggerBaseImpl{ + EndTime: s.EndTime, + StartTime: s.StartTime, + TimeZone: s.TimeZone, + TriggerType: s.TriggerType, + } +} + +var _ json.Marshaler = CronTrigger{} + +func (s CronTrigger) MarshalJSON() ([]byte, error) { + type wrapper CronTrigger + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CronTrigger: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CronTrigger: %+v", err) + } + + decoded["triggerType"] = "Cron" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CronTrigger: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_featuresetspecification.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_featuresetspecification.go new file mode 100644 index 00000000000..fbd3b25f21e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_featuresetspecification.go @@ -0,0 +1,8 @@ +package featuresetversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FeaturesetSpecification struct { + Path *string `json:"path,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_featuresetversion.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_featuresetversion.go new file mode 100644 index 00000000000..1bb90fc9081 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_featuresetversion.go @@ -0,0 +1,17 @@ +package featuresetversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FeaturesetVersion struct { + Description *string `json:"description,omitempty"` + Entities *[]string `json:"entities,omitempty"` + IsAnonymous *bool `json:"isAnonymous,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + MaterializationSettings *MaterializationSettings `json:"materializationSettings,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ProvisioningState *AssetProvisioningState `json:"provisioningState,omitempty"` + Specification *FeaturesetSpecification `json:"specification,omitempty"` + Stage *string `json:"stage,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_featuresetversionbackfillrequest.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_featuresetversionbackfillrequest.go new file mode 100644 index 00000000000..44e59ac7081 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_featuresetversionbackfillrequest.go @@ -0,0 +1,16 @@ +package featuresetversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FeaturesetVersionBackfillRequest struct { + DataAvailabilityStatus *[]DataAvailabilityStatus `json:"dataAvailabilityStatus,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + FeatureWindow *FeatureWindow `json:"featureWindow,omitempty"` + JobId *string `json:"jobId,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Resource *MaterializationComputeResource `json:"resource,omitempty"` + SparkConfiguration *map[string]string `json:"sparkConfiguration,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_featuresetversionbackfillresponse.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_featuresetversionbackfillresponse.go new file mode 100644 index 00000000000..a4af0c8c592 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_featuresetversionbackfillresponse.go @@ -0,0 +1,8 @@ +package featuresetversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FeaturesetVersionBackfillResponse struct { + JobIds *[]string `json:"jobIds,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_featuresetversionresource.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_featuresetversionresource.go new file mode 100644 index 00000000000..52abb7e8945 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_featuresetversionresource.go @@ -0,0 +1,16 @@ +package featuresetversion + +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 FeaturesetVersionResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties FeaturesetVersion `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_featurewindow.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_featurewindow.go new file mode 100644 index 00000000000..69490ddf60b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_featurewindow.go @@ -0,0 +1,39 @@ +package featuresetversion + +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 FeatureWindow struct { + FeatureWindowEnd *string `json:"featureWindowEnd,omitempty"` + FeatureWindowStart *string `json:"featureWindowStart,omitempty"` +} + +func (o *FeatureWindow) GetFeatureWindowEndAsTime() (*time.Time, error) { + if o.FeatureWindowEnd == nil { + return nil, nil + } + return dates.ParseAsFormat(o.FeatureWindowEnd, "2006-01-02T15:04:05Z07:00") +} + +func (o *FeatureWindow) SetFeatureWindowEndAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.FeatureWindowEnd = &formatted +} + +func (o *FeatureWindow) GetFeatureWindowStartAsTime() (*time.Time, error) { + if o.FeatureWindowStart == nil { + return nil, nil + } + return dates.ParseAsFormat(o.FeatureWindowStart, "2006-01-02T15:04:05Z07:00") +} + +func (o *FeatureWindow) SetFeatureWindowStartAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.FeatureWindowStart = &formatted +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_materializationcomputeresource.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_materializationcomputeresource.go new file mode 100644 index 00000000000..934111e2435 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_materializationcomputeresource.go @@ -0,0 +1,8 @@ +package featuresetversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MaterializationComputeResource struct { + InstanceType *string `json:"instanceType,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_materializationsettings.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_materializationsettings.go new file mode 100644 index 00000000000..be80c2702a4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_materializationsettings.go @@ -0,0 +1,12 @@ +package featuresetversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MaterializationSettings struct { + Notification *NotificationSetting `json:"notification,omitempty"` + Resource *MaterializationComputeResource `json:"resource,omitempty"` + Schedule *RecurrenceTrigger `json:"schedule,omitempty"` + SparkConfiguration *map[string]string `json:"sparkConfiguration,omitempty"` + StoreType *MaterializationStoreType `json:"storeType,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_notificationsetting.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_notificationsetting.go new file mode 100644 index 00000000000..a2a94f52d9b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_notificationsetting.go @@ -0,0 +1,54 @@ +package featuresetversion + +import ( + "encoding/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 NotificationSetting struct { + EmailOn *[]EmailNotificationEnableType `json:"emailOn,omitempty"` + Emails *[]string `json:"emails,omitempty"` + WebHooks *map[string]Webhook `json:"webhooks,omitempty"` +} + +var _ json.Unmarshaler = &NotificationSetting{} + +func (s *NotificationSetting) UnmarshalJSON(bytes []byte) error { + var decoded struct { + EmailOn *[]EmailNotificationEnableType `json:"emailOn,omitempty"` + Emails *[]string `json:"emails,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.EmailOn = decoded.EmailOn + s.Emails = decoded.Emails + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling NotificationSetting into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["webhooks"]; ok { + var dictionaryTemp map[string]json.RawMessage + if err := json.Unmarshal(v, &dictionaryTemp); err != nil { + return fmt.Errorf("unmarshaling WebHooks into dictionary map[string]json.RawMessage: %+v", err) + } + + output := make(map[string]Webhook) + for key, val := range dictionaryTemp { + impl, err := UnmarshalWebhookImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling key %q field 'WebHooks' for 'NotificationSetting': %+v", key, err) + } + output[key] = impl + } + s.WebHooks = &output + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_recurrenceschedule.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_recurrenceschedule.go new file mode 100644 index 00000000000..f7036fcc076 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_recurrenceschedule.go @@ -0,0 +1,11 @@ +package featuresetversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecurrenceSchedule struct { + Hours []int64 `json:"hours"` + Minutes []int64 `json:"minutes"` + MonthDays *[]int64 `json:"monthDays,omitempty"` + WeekDays *[]WeekDay `json:"weekDays,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_recurrencetrigger.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_recurrencetrigger.go new file mode 100644 index 00000000000..64719c65aec --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_recurrencetrigger.go @@ -0,0 +1,58 @@ +package featuresetversion + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TriggerBase = RecurrenceTrigger{} + +type RecurrenceTrigger struct { + Frequency RecurrenceFrequency `json:"frequency"` + Interval int64 `json:"interval"` + Schedule *RecurrenceSchedule `json:"schedule,omitempty"` + + // Fields inherited from TriggerBase + + EndTime *string `json:"endTime,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + TriggerType TriggerType `json:"triggerType"` +} + +func (s RecurrenceTrigger) TriggerBase() BaseTriggerBaseImpl { + return BaseTriggerBaseImpl{ + EndTime: s.EndTime, + StartTime: s.StartTime, + TimeZone: s.TimeZone, + TriggerType: s.TriggerType, + } +} + +var _ json.Marshaler = RecurrenceTrigger{} + +func (s RecurrenceTrigger) MarshalJSON() ([]byte, error) { + type wrapper RecurrenceTrigger + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecurrenceTrigger: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecurrenceTrigger: %+v", err) + } + + decoded["triggerType"] = "Recurrence" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecurrenceTrigger: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_triggerbase.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_triggerbase.go new file mode 100644 index 00000000000..a11aa1ff4e9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_triggerbase.go @@ -0,0 +1,86 @@ +package featuresetversion + +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 TriggerBase interface { + TriggerBase() BaseTriggerBaseImpl +} + +var _ TriggerBase = BaseTriggerBaseImpl{} + +type BaseTriggerBaseImpl struct { + EndTime *string `json:"endTime,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + TriggerType TriggerType `json:"triggerType"` +} + +func (s BaseTriggerBaseImpl) TriggerBase() BaseTriggerBaseImpl { + return s +} + +var _ TriggerBase = RawTriggerBaseImpl{} + +// RawTriggerBaseImpl 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 RawTriggerBaseImpl struct { + triggerBase BaseTriggerBaseImpl + Type string + Values map[string]interface{} +} + +func (s RawTriggerBaseImpl) TriggerBase() BaseTriggerBaseImpl { + return s.triggerBase +} + +func UnmarshalTriggerBaseImplementation(input []byte) (TriggerBase, 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 TriggerBase into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["triggerType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Cron") { + var out CronTrigger + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CronTrigger: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Recurrence") { + var out RecurrenceTrigger + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecurrenceTrigger: %+v", err) + } + return out, nil + } + + var parent BaseTriggerBaseImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseTriggerBaseImpl: %+v", err) + } + + return RawTriggerBaseImpl{ + triggerBase: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_webhook.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_webhook.go new file mode 100644 index 00000000000..c1f2e82a373 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/model_webhook.go @@ -0,0 +1,76 @@ +package featuresetversion + +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 Webhook interface { + Webhook() BaseWebhookImpl +} + +var _ Webhook = BaseWebhookImpl{} + +type BaseWebhookImpl struct { + EventType *string `json:"eventType,omitempty"` + WebhookType WebhookType `json:"webhookType"` +} + +func (s BaseWebhookImpl) Webhook() BaseWebhookImpl { + return s +} + +var _ Webhook = RawWebhookImpl{} + +// RawWebhookImpl 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 RawWebhookImpl struct { + webhook BaseWebhookImpl + Type string + Values map[string]interface{} +} + +func (s RawWebhookImpl) Webhook() BaseWebhookImpl { + return s.webhook +} + +func UnmarshalWebhookImplementation(input []byte) (Webhook, 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 Webhook into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["webhookType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AzureDevOps") { + var out AzureDevOpsWebhook + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureDevOpsWebhook: %+v", err) + } + return out, nil + } + + var parent BaseWebhookImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseWebhookImpl: %+v", err) + } + + return RawWebhookImpl{ + webhook: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featuresetversion/predicates.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/predicates.go new file mode 100644 index 00000000000..cf69b8935f6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/predicates.go @@ -0,0 +1,27 @@ +package featuresetversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FeaturesetVersionResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p FeaturesetVersionResourceOperationPredicate) Matches(input FeaturesetVersionResource) 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/machinelearningservices/2025-04-01/featuresetversion/version.go b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/version.go new file mode 100644 index 00000000000..a06c130c428 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featuresetversion/version.go @@ -0,0 +1,10 @@ +package featuresetversion + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/featuresetversion/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/README.md b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/README.md new file mode 100644 index 00000000000..1b1ac575e04 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer` Documentation + +The `featurestoreentitycontainer` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer" +``` + + +### Client Initialization + +```go +client := featurestoreentitycontainer.NewFeaturestoreEntityContainerClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `FeaturestoreEntityContainerClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := featurestoreentitycontainer.NewFeatureStoreEntityID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureStoreEntityName") + +payload := featurestoreentitycontainer.FeaturestoreEntityContainerResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `FeaturestoreEntityContainerClient.Delete` + +```go +ctx := context.TODO() +id := featurestoreentitycontainer.NewFeatureStoreEntityID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureStoreEntityName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `FeaturestoreEntityContainerClient.GetEntity` + +```go +ctx := context.TODO() +id := featurestoreentitycontainer.NewFeatureStoreEntityID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureStoreEntityName") + +read, err := client.GetEntity(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `FeaturestoreEntityContainerClient.List` + +```go +ctx := context.TODO() +id := featurestoreentitycontainer.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +// alternatively `client.List(ctx, id, featurestoreentitycontainer.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, featurestoreentitycontainer.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/client.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/client.go new file mode 100644 index 00000000000..c13e2e5b12d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/client.go @@ -0,0 +1,26 @@ +package featurestoreentitycontainer + +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 FeaturestoreEntityContainerClient struct { + Client *resourcemanager.Client +} + +func NewFeaturestoreEntityContainerClientWithBaseURI(sdkApi sdkEnv.Api) (*FeaturestoreEntityContainerClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "featurestoreentitycontainer", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating FeaturestoreEntityContainerClient: %+v", err) + } + + return &FeaturestoreEntityContainerClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/constants.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/constants.go new file mode 100644 index 00000000000..92b336ac83b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/constants.go @@ -0,0 +1,107 @@ +package featurestoreentitycontainer + +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 AssetProvisioningState string + +const ( + AssetProvisioningStateCanceled AssetProvisioningState = "Canceled" + AssetProvisioningStateCreating AssetProvisioningState = "Creating" + AssetProvisioningStateDeleting AssetProvisioningState = "Deleting" + AssetProvisioningStateFailed AssetProvisioningState = "Failed" + AssetProvisioningStateSucceeded AssetProvisioningState = "Succeeded" + AssetProvisioningStateUpdating AssetProvisioningState = "Updating" +) + +func PossibleValuesForAssetProvisioningState() []string { + return []string{ + string(AssetProvisioningStateCanceled), + string(AssetProvisioningStateCreating), + string(AssetProvisioningStateDeleting), + string(AssetProvisioningStateFailed), + string(AssetProvisioningStateSucceeded), + string(AssetProvisioningStateUpdating), + } +} + +func (s *AssetProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAssetProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAssetProvisioningState(input string) (*AssetProvisioningState, error) { + vals := map[string]AssetProvisioningState{ + "canceled": AssetProvisioningStateCanceled, + "creating": AssetProvisioningStateCreating, + "deleting": AssetProvisioningStateDeleting, + "failed": AssetProvisioningStateFailed, + "succeeded": AssetProvisioningStateSucceeded, + "updating": AssetProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AssetProvisioningState(input) + return &out, nil +} + +type ListViewType string + +const ( + ListViewTypeActiveOnly ListViewType = "ActiveOnly" + ListViewTypeAll ListViewType = "All" + ListViewTypeArchivedOnly ListViewType = "ArchivedOnly" +) + +func PossibleValuesForListViewType() []string { + return []string{ + string(ListViewTypeActiveOnly), + string(ListViewTypeAll), + string(ListViewTypeArchivedOnly), + } +} + +func (s *ListViewType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseListViewType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseListViewType(input string) (*ListViewType, error) { + vals := map[string]ListViewType{ + "activeonly": ListViewTypeActiveOnly, + "all": ListViewTypeAll, + "archivedonly": ListViewTypeArchivedOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ListViewType(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/id_featurestoreentity.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/id_featurestoreentity.go new file mode 100644 index 00000000000..3fdbe1b064d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/id_featurestoreentity.go @@ -0,0 +1,139 @@ +package featurestoreentitycontainer + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&FeatureStoreEntityId{}) +} + +var _ resourceids.ResourceId = &FeatureStoreEntityId{} + +// FeatureStoreEntityId is a struct representing the Resource ID for a Feature Store Entity +type FeatureStoreEntityId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + FeatureStoreEntityName string +} + +// NewFeatureStoreEntityID returns a new FeatureStoreEntityId struct +func NewFeatureStoreEntityID(subscriptionId string, resourceGroupName string, workspaceName string, featureStoreEntityName string) FeatureStoreEntityId { + return FeatureStoreEntityId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + FeatureStoreEntityName: featureStoreEntityName, + } +} + +// ParseFeatureStoreEntityID parses 'input' into a FeatureStoreEntityId +func ParseFeatureStoreEntityID(input string) (*FeatureStoreEntityId, error) { + parser := resourceids.NewParserFromResourceIdType(&FeatureStoreEntityId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FeatureStoreEntityId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFeatureStoreEntityIDInsensitively parses 'input' case-insensitively into a FeatureStoreEntityId +// note: this method should only be used for API response data and not user input +func ParseFeatureStoreEntityIDInsensitively(input string) (*FeatureStoreEntityId, error) { + parser := resourceids.NewParserFromResourceIdType(&FeatureStoreEntityId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FeatureStoreEntityId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FeatureStoreEntityId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.FeatureStoreEntityName, ok = input.Parsed["featureStoreEntityName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "featureStoreEntityName", input) + } + + return nil +} + +// ValidateFeatureStoreEntityID checks that 'input' can be parsed as a Feature Store Entity ID +func ValidateFeatureStoreEntityID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseFeatureStoreEntityID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Feature Store Entity ID +func (id FeatureStoreEntityId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/featureStoreEntities/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.FeatureStoreEntityName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Feature Store Entity ID +func (id FeatureStoreEntityId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticFeatureStoreEntities", "featureStoreEntities", "featureStoreEntities"), + resourceids.UserSpecifiedSegment("featureStoreEntityName", "featureStoreEntityName"), + } +} + +// String returns a human-readable description of this Feature Store Entity ID +func (id FeatureStoreEntityId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Feature Store Entity Name: %q", id.FeatureStoreEntityName), + } + return fmt.Sprintf("Feature Store Entity (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/id_featurestoreentity_test.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/id_featurestoreentity_test.go new file mode 100644 index 00000000000..e4325a1d721 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/id_featurestoreentity_test.go @@ -0,0 +1,327 @@ +package featurestoreentitycontainer + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &FeatureStoreEntityId{} + +func TestNewFeatureStoreEntityID(t *testing.T) { + id := NewFeatureStoreEntityID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureStoreEntityName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.FeatureStoreEntityName != "featureStoreEntityName" { + t.Fatalf("Expected %q but got %q for Segment 'FeatureStoreEntityName'", id.FeatureStoreEntityName, "featureStoreEntityName") + } +} + +func TestFormatFeatureStoreEntityID(t *testing.T) { + actual := NewFeatureStoreEntityID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureStoreEntityName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureStoreEntities/featureStoreEntityName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFeatureStoreEntityID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FeatureStoreEntityId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureStoreEntities", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureStoreEntities/featureStoreEntityName", + Expected: &FeatureStoreEntityId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + FeatureStoreEntityName: "featureStoreEntityName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureStoreEntities/featureStoreEntityName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFeatureStoreEntityID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.FeatureStoreEntityName != v.Expected.FeatureStoreEntityName { + t.Fatalf("Expected %q but got %q for FeatureStoreEntityName", v.Expected.FeatureStoreEntityName, actual.FeatureStoreEntityName) + } + + } +} + +func TestParseFeatureStoreEntityIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FeatureStoreEntityId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureStoreEntities", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReStOrEeNtItIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureStoreEntities/featureStoreEntityName", + Expected: &FeatureStoreEntityId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + FeatureStoreEntityName: "featureStoreEntityName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureStoreEntities/featureStoreEntityName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReStOrEeNtItIeS/fEaTuReStOrEeNtItYnAmE", + Expected: &FeatureStoreEntityId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + FeatureStoreEntityName: "fEaTuReStOrEeNtItYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReStOrEeNtItIeS/fEaTuReStOrEeNtItYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFeatureStoreEntityIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.FeatureStoreEntityName != v.Expected.FeatureStoreEntityName { + t.Fatalf("Expected %q but got %q for FeatureStoreEntityName", v.Expected.FeatureStoreEntityName, actual.FeatureStoreEntityName) + } + + } +} + +func TestSegmentsForFeatureStoreEntityId(t *testing.T) { + segments := FeatureStoreEntityId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FeatureStoreEntityId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/id_workspace.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/id_workspace.go new file mode 100644 index 00000000000..d2133997f88 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/id_workspace.go @@ -0,0 +1,130 @@ +package featurestoreentitycontainer + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/id_workspace_test.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/id_workspace_test.go new file mode 100644 index 00000000000..d9c9d45c9b8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/id_workspace_test.go @@ -0,0 +1,282 @@ +package featurestoreentitycontainer + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/method_createorupdate.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/method_createorupdate.go new file mode 100644 index 00000000000..69d79215e87 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/method_createorupdate.go @@ -0,0 +1,75 @@ +package featurestoreentitycontainer + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *FeaturestoreEntityContainerResource +} + +// CreateOrUpdate ... +func (c FeaturestoreEntityContainerClient) CreateOrUpdate(ctx context.Context, id FeatureStoreEntityId, input FeaturestoreEntityContainerResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c FeaturestoreEntityContainerClient) CreateOrUpdateThenPoll(ctx context.Context, id FeatureStoreEntityId, input FeaturestoreEntityContainerResource) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/method_delete.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/method_delete.go new file mode 100644 index 00000000000..695e92074b3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/method_delete.go @@ -0,0 +1,71 @@ +package featurestoreentitycontainer + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 FeaturestoreEntityContainerClient) Delete(ctx context.Context, id FeatureStoreEntityId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c FeaturestoreEntityContainerClient) DeleteThenPoll(ctx context.Context, id FeatureStoreEntityId) 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/machinelearningservices/2025-04-01/featurestoreentitycontainer/method_getentity.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/method_getentity.go new file mode 100644 index 00000000000..20992ddf5b4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/method_getentity.go @@ -0,0 +1,53 @@ +package featurestoreentitycontainer + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetEntityOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *FeaturestoreEntityContainerResource +} + +// GetEntity ... +func (c FeaturestoreEntityContainerClient) GetEntity(ctx context.Context, id FeatureStoreEntityId) (result GetEntityOperationResponse, 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 FeaturestoreEntityContainerResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/method_list.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/method_list.go new file mode 100644 index 00000000000..9d2dfc6d7f3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/method_list.go @@ -0,0 +1,158 @@ +package featurestoreentitycontainer + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]FeaturestoreEntityContainerResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []FeaturestoreEntityContainerResource +} + +type ListOperationOptions struct { + CreatedBy *string + Description *string + ListViewType *ListViewType + Name *string + PageSize *int64 + Skip *string + Tags *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.CreatedBy != nil { + out.Append("createdBy", fmt.Sprintf("%v", *o.CreatedBy)) + } + if o.Description != nil { + out.Append("description", fmt.Sprintf("%v", *o.Description)) + } + if o.ListViewType != nil { + out.Append("listViewType", fmt.Sprintf("%v", *o.ListViewType)) + } + if o.Name != nil { + out.Append("name", fmt.Sprintf("%v", *o.Name)) + } + if o.PageSize != nil { + out.Append("pageSize", fmt.Sprintf("%v", *o.PageSize)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Tags != nil { + out.Append("tags", fmt.Sprintf("%v", *o.Tags)) + } + 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 FeaturestoreEntityContainerClient) List(ctx context.Context, id WorkspaceId, 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/featureStoreEntities", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]FeaturestoreEntityContainerResource `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 FeaturestoreEntityContainerClient) ListComplete(ctx context.Context, id WorkspaceId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, FeaturestoreEntityContainerResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c FeaturestoreEntityContainerClient) ListCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, options ListOperationOptions, predicate FeaturestoreEntityContainerResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]FeaturestoreEntityContainerResource, 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/machinelearningservices/2025-04-01/featurestoreentitycontainer/model_featurestoreentitycontainer.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/model_featurestoreentitycontainer.go new file mode 100644 index 00000000000..b9d28165f58 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/model_featurestoreentitycontainer.go @@ -0,0 +1,14 @@ +package featurestoreentitycontainer + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FeaturestoreEntityContainer struct { + Description *string `json:"description,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + LatestVersion *string `json:"latestVersion,omitempty"` + NextVersion *string `json:"nextVersion,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ProvisioningState *AssetProvisioningState `json:"provisioningState,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/model_featurestoreentitycontainerresource.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/model_featurestoreentitycontainerresource.go new file mode 100644 index 00000000000..2044b568e1b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/model_featurestoreentitycontainerresource.go @@ -0,0 +1,16 @@ +package featurestoreentitycontainer + +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 FeaturestoreEntityContainerResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties FeaturestoreEntityContainer `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/predicates.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/predicates.go new file mode 100644 index 00000000000..70646f863e6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/predicates.go @@ -0,0 +1,27 @@ +package featurestoreentitycontainer + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FeaturestoreEntityContainerResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p FeaturestoreEntityContainerResourceOperationPredicate) Matches(input FeaturestoreEntityContainerResource) 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/machinelearningservices/2025-04-01/featurestoreentitycontainer/version.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/version.go new file mode 100644 index 00000000000..c91bed5a453 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentitycontainer/version.go @@ -0,0 +1,10 @@ +package featurestoreentitycontainer + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/featurestoreentitycontainer/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/README.md b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/README.md new file mode 100644 index 00000000000..69d439e0d8c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion` Documentation + +The `featurestoreentityversion` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion" +``` + + +### Client Initialization + +```go +client := featurestoreentityversion.NewFeaturestoreEntityVersionClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `FeaturestoreEntityVersionClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := featurestoreentityversion.NewFeatureStoreEntityVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureStoreEntityName", "versionName") + +payload := featurestoreentityversion.FeaturestoreEntityVersionResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `FeaturestoreEntityVersionClient.Delete` + +```go +ctx := context.TODO() +id := featurestoreentityversion.NewFeatureStoreEntityVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureStoreEntityName", "versionName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `FeaturestoreEntityVersionClient.Get` + +```go +ctx := context.TODO() +id := featurestoreentityversion.NewFeatureStoreEntityVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureStoreEntityName", "versionName") + +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: `FeaturestoreEntityVersionClient.List` + +```go +ctx := context.TODO() +id := featurestoreentityversion.NewFeatureStoreEntityID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureStoreEntityName") + +// alternatively `client.List(ctx, id, featurestoreentityversion.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, featurestoreentityversion.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/client.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/client.go new file mode 100644 index 00000000000..843363442eb --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/client.go @@ -0,0 +1,26 @@ +package featurestoreentityversion + +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 FeaturestoreEntityVersionClient struct { + Client *resourcemanager.Client +} + +func NewFeaturestoreEntityVersionClientWithBaseURI(sdkApi sdkEnv.Api) (*FeaturestoreEntityVersionClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "featurestoreentityversion", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating FeaturestoreEntityVersionClient: %+v", err) + } + + return &FeaturestoreEntityVersionClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/constants.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/constants.go new file mode 100644 index 00000000000..b862c5bcee3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/constants.go @@ -0,0 +1,166 @@ +package featurestoreentityversion + +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 AssetProvisioningState string + +const ( + AssetProvisioningStateCanceled AssetProvisioningState = "Canceled" + AssetProvisioningStateCreating AssetProvisioningState = "Creating" + AssetProvisioningStateDeleting AssetProvisioningState = "Deleting" + AssetProvisioningStateFailed AssetProvisioningState = "Failed" + AssetProvisioningStateSucceeded AssetProvisioningState = "Succeeded" + AssetProvisioningStateUpdating AssetProvisioningState = "Updating" +) + +func PossibleValuesForAssetProvisioningState() []string { + return []string{ + string(AssetProvisioningStateCanceled), + string(AssetProvisioningStateCreating), + string(AssetProvisioningStateDeleting), + string(AssetProvisioningStateFailed), + string(AssetProvisioningStateSucceeded), + string(AssetProvisioningStateUpdating), + } +} + +func (s *AssetProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAssetProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAssetProvisioningState(input string) (*AssetProvisioningState, error) { + vals := map[string]AssetProvisioningState{ + "canceled": AssetProvisioningStateCanceled, + "creating": AssetProvisioningStateCreating, + "deleting": AssetProvisioningStateDeleting, + "failed": AssetProvisioningStateFailed, + "succeeded": AssetProvisioningStateSucceeded, + "updating": AssetProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AssetProvisioningState(input) + return &out, nil +} + +type FeatureDataType string + +const ( + FeatureDataTypeBinary FeatureDataType = "Binary" + FeatureDataTypeBoolean FeatureDataType = "Boolean" + FeatureDataTypeDatetime FeatureDataType = "Datetime" + FeatureDataTypeDouble FeatureDataType = "Double" + FeatureDataTypeFloat FeatureDataType = "Float" + FeatureDataTypeInteger FeatureDataType = "Integer" + FeatureDataTypeLong FeatureDataType = "Long" + FeatureDataTypeString FeatureDataType = "String" +) + +func PossibleValuesForFeatureDataType() []string { + return []string{ + string(FeatureDataTypeBinary), + string(FeatureDataTypeBoolean), + string(FeatureDataTypeDatetime), + string(FeatureDataTypeDouble), + string(FeatureDataTypeFloat), + string(FeatureDataTypeInteger), + string(FeatureDataTypeLong), + string(FeatureDataTypeString), + } +} + +func (s *FeatureDataType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFeatureDataType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFeatureDataType(input string) (*FeatureDataType, error) { + vals := map[string]FeatureDataType{ + "binary": FeatureDataTypeBinary, + "boolean": FeatureDataTypeBoolean, + "datetime": FeatureDataTypeDatetime, + "double": FeatureDataTypeDouble, + "float": FeatureDataTypeFloat, + "integer": FeatureDataTypeInteger, + "long": FeatureDataTypeLong, + "string": FeatureDataTypeString, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FeatureDataType(input) + return &out, nil +} + +type ListViewType string + +const ( + ListViewTypeActiveOnly ListViewType = "ActiveOnly" + ListViewTypeAll ListViewType = "All" + ListViewTypeArchivedOnly ListViewType = "ArchivedOnly" +) + +func PossibleValuesForListViewType() []string { + return []string{ + string(ListViewTypeActiveOnly), + string(ListViewTypeAll), + string(ListViewTypeArchivedOnly), + } +} + +func (s *ListViewType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseListViewType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseListViewType(input string) (*ListViewType, error) { + vals := map[string]ListViewType{ + "activeonly": ListViewTypeActiveOnly, + "all": ListViewTypeAll, + "archivedonly": ListViewTypeArchivedOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ListViewType(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/id_featurestoreentity.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/id_featurestoreentity.go new file mode 100644 index 00000000000..e9e51c9f425 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/id_featurestoreentity.go @@ -0,0 +1,139 @@ +package featurestoreentityversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&FeatureStoreEntityId{}) +} + +var _ resourceids.ResourceId = &FeatureStoreEntityId{} + +// FeatureStoreEntityId is a struct representing the Resource ID for a Feature Store Entity +type FeatureStoreEntityId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + FeatureStoreEntityName string +} + +// NewFeatureStoreEntityID returns a new FeatureStoreEntityId struct +func NewFeatureStoreEntityID(subscriptionId string, resourceGroupName string, workspaceName string, featureStoreEntityName string) FeatureStoreEntityId { + return FeatureStoreEntityId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + FeatureStoreEntityName: featureStoreEntityName, + } +} + +// ParseFeatureStoreEntityID parses 'input' into a FeatureStoreEntityId +func ParseFeatureStoreEntityID(input string) (*FeatureStoreEntityId, error) { + parser := resourceids.NewParserFromResourceIdType(&FeatureStoreEntityId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FeatureStoreEntityId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFeatureStoreEntityIDInsensitively parses 'input' case-insensitively into a FeatureStoreEntityId +// note: this method should only be used for API response data and not user input +func ParseFeatureStoreEntityIDInsensitively(input string) (*FeatureStoreEntityId, error) { + parser := resourceids.NewParserFromResourceIdType(&FeatureStoreEntityId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FeatureStoreEntityId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FeatureStoreEntityId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.FeatureStoreEntityName, ok = input.Parsed["featureStoreEntityName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "featureStoreEntityName", input) + } + + return nil +} + +// ValidateFeatureStoreEntityID checks that 'input' can be parsed as a Feature Store Entity ID +func ValidateFeatureStoreEntityID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseFeatureStoreEntityID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Feature Store Entity ID +func (id FeatureStoreEntityId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/featureStoreEntities/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.FeatureStoreEntityName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Feature Store Entity ID +func (id FeatureStoreEntityId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticFeatureStoreEntities", "featureStoreEntities", "featureStoreEntities"), + resourceids.UserSpecifiedSegment("featureStoreEntityName", "featureStoreEntityName"), + } +} + +// String returns a human-readable description of this Feature Store Entity ID +func (id FeatureStoreEntityId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Feature Store Entity Name: %q", id.FeatureStoreEntityName), + } + return fmt.Sprintf("Feature Store Entity (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/id_featurestoreentity_test.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/id_featurestoreentity_test.go new file mode 100644 index 00000000000..e7e27fcd80c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/id_featurestoreentity_test.go @@ -0,0 +1,327 @@ +package featurestoreentityversion + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &FeatureStoreEntityId{} + +func TestNewFeatureStoreEntityID(t *testing.T) { + id := NewFeatureStoreEntityID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureStoreEntityName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.FeatureStoreEntityName != "featureStoreEntityName" { + t.Fatalf("Expected %q but got %q for Segment 'FeatureStoreEntityName'", id.FeatureStoreEntityName, "featureStoreEntityName") + } +} + +func TestFormatFeatureStoreEntityID(t *testing.T) { + actual := NewFeatureStoreEntityID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureStoreEntityName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureStoreEntities/featureStoreEntityName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFeatureStoreEntityID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FeatureStoreEntityId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureStoreEntities", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureStoreEntities/featureStoreEntityName", + Expected: &FeatureStoreEntityId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + FeatureStoreEntityName: "featureStoreEntityName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureStoreEntities/featureStoreEntityName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFeatureStoreEntityID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.FeatureStoreEntityName != v.Expected.FeatureStoreEntityName { + t.Fatalf("Expected %q but got %q for FeatureStoreEntityName", v.Expected.FeatureStoreEntityName, actual.FeatureStoreEntityName) + } + + } +} + +func TestParseFeatureStoreEntityIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FeatureStoreEntityId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureStoreEntities", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReStOrEeNtItIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureStoreEntities/featureStoreEntityName", + Expected: &FeatureStoreEntityId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + FeatureStoreEntityName: "featureStoreEntityName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureStoreEntities/featureStoreEntityName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReStOrEeNtItIeS/fEaTuReStOrEeNtItYnAmE", + Expected: &FeatureStoreEntityId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + FeatureStoreEntityName: "fEaTuReStOrEeNtItYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReStOrEeNtItIeS/fEaTuReStOrEeNtItYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFeatureStoreEntityIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.FeatureStoreEntityName != v.Expected.FeatureStoreEntityName { + t.Fatalf("Expected %q but got %q for FeatureStoreEntityName", v.Expected.FeatureStoreEntityName, actual.FeatureStoreEntityName) + } + + } +} + +func TestSegmentsForFeatureStoreEntityId(t *testing.T) { + segments := FeatureStoreEntityId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FeatureStoreEntityId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/id_featurestoreentityversion.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/id_featurestoreentityversion.go new file mode 100644 index 00000000000..66adaecc8d4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/id_featurestoreentityversion.go @@ -0,0 +1,148 @@ +package featurestoreentityversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&FeatureStoreEntityVersionId{}) +} + +var _ resourceids.ResourceId = &FeatureStoreEntityVersionId{} + +// FeatureStoreEntityVersionId is a struct representing the Resource ID for a Feature Store Entity Version +type FeatureStoreEntityVersionId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + FeatureStoreEntityName string + VersionName string +} + +// NewFeatureStoreEntityVersionID returns a new FeatureStoreEntityVersionId struct +func NewFeatureStoreEntityVersionID(subscriptionId string, resourceGroupName string, workspaceName string, featureStoreEntityName string, versionName string) FeatureStoreEntityVersionId { + return FeatureStoreEntityVersionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + FeatureStoreEntityName: featureStoreEntityName, + VersionName: versionName, + } +} + +// ParseFeatureStoreEntityVersionID parses 'input' into a FeatureStoreEntityVersionId +func ParseFeatureStoreEntityVersionID(input string) (*FeatureStoreEntityVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&FeatureStoreEntityVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FeatureStoreEntityVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseFeatureStoreEntityVersionIDInsensitively parses 'input' case-insensitively into a FeatureStoreEntityVersionId +// note: this method should only be used for API response data and not user input +func ParseFeatureStoreEntityVersionIDInsensitively(input string) (*FeatureStoreEntityVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&FeatureStoreEntityVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := FeatureStoreEntityVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *FeatureStoreEntityVersionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.FeatureStoreEntityName, ok = input.Parsed["featureStoreEntityName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "featureStoreEntityName", input) + } + + if id.VersionName, ok = input.Parsed["versionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "versionName", input) + } + + return nil +} + +// ValidateFeatureStoreEntityVersionID checks that 'input' can be parsed as a Feature Store Entity Version ID +func ValidateFeatureStoreEntityVersionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseFeatureStoreEntityVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Feature Store Entity Version ID +func (id FeatureStoreEntityVersionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/featureStoreEntities/%s/versions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.FeatureStoreEntityName, id.VersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Feature Store Entity Version ID +func (id FeatureStoreEntityVersionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticFeatureStoreEntities", "featureStoreEntities", "featureStoreEntities"), + resourceids.UserSpecifiedSegment("featureStoreEntityName", "featureStoreEntityName"), + resourceids.StaticSegment("staticVersions", "versions", "versions"), + resourceids.UserSpecifiedSegment("versionName", "versionName"), + } +} + +// String returns a human-readable description of this Feature Store Entity Version ID +func (id FeatureStoreEntityVersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Feature Store Entity Name: %q", id.FeatureStoreEntityName), + fmt.Sprintf("Version Name: %q", id.VersionName), + } + return fmt.Sprintf("Feature Store Entity Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/id_featurestoreentityversion_test.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/id_featurestoreentityversion_test.go new file mode 100644 index 00000000000..34c73e777f8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/id_featurestoreentityversion_test.go @@ -0,0 +1,372 @@ +package featurestoreentityversion + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &FeatureStoreEntityVersionId{} + +func TestNewFeatureStoreEntityVersionID(t *testing.T) { + id := NewFeatureStoreEntityVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureStoreEntityName", "versionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.FeatureStoreEntityName != "featureStoreEntityName" { + t.Fatalf("Expected %q but got %q for Segment 'FeatureStoreEntityName'", id.FeatureStoreEntityName, "featureStoreEntityName") + } + + if id.VersionName != "versionName" { + t.Fatalf("Expected %q but got %q for Segment 'VersionName'", id.VersionName, "versionName") + } +} + +func TestFormatFeatureStoreEntityVersionID(t *testing.T) { + actual := NewFeatureStoreEntityVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "featureStoreEntityName", "versionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureStoreEntities/featureStoreEntityName/versions/versionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseFeatureStoreEntityVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FeatureStoreEntityVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureStoreEntities", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureStoreEntities/featureStoreEntityName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureStoreEntities/featureStoreEntityName/versions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureStoreEntities/featureStoreEntityName/versions/versionName", + Expected: &FeatureStoreEntityVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + FeatureStoreEntityName: "featureStoreEntityName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureStoreEntities/featureStoreEntityName/versions/versionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFeatureStoreEntityVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.FeatureStoreEntityName != v.Expected.FeatureStoreEntityName { + t.Fatalf("Expected %q but got %q for FeatureStoreEntityName", v.Expected.FeatureStoreEntityName, actual.FeatureStoreEntityName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestParseFeatureStoreEntityVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *FeatureStoreEntityVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureStoreEntities", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReStOrEeNtItIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureStoreEntities/featureStoreEntityName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReStOrEeNtItIeS/fEaTuReStOrEeNtItYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureStoreEntities/featureStoreEntityName/versions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReStOrEeNtItIeS/fEaTuReStOrEeNtItYnAmE/vErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureStoreEntities/featureStoreEntityName/versions/versionName", + Expected: &FeatureStoreEntityVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + FeatureStoreEntityName: "featureStoreEntityName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/featureStoreEntities/featureStoreEntityName/versions/versionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReStOrEeNtItIeS/fEaTuReStOrEeNtItYnAmE/vErSiOnS/vErSiOnNaMe", + Expected: &FeatureStoreEntityVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + FeatureStoreEntityName: "fEaTuReStOrEeNtItYnAmE", + VersionName: "vErSiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/fEaTuReStOrEeNtItIeS/fEaTuReStOrEeNtItYnAmE/vErSiOnS/vErSiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseFeatureStoreEntityVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.FeatureStoreEntityName != v.Expected.FeatureStoreEntityName { + t.Fatalf("Expected %q but got %q for FeatureStoreEntityName", v.Expected.FeatureStoreEntityName, actual.FeatureStoreEntityName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestSegmentsForFeatureStoreEntityVersionId(t *testing.T) { + segments := FeatureStoreEntityVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("FeatureStoreEntityVersionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/method_createorupdate.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/method_createorupdate.go new file mode 100644 index 00000000000..4ea42f55f25 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/method_createorupdate.go @@ -0,0 +1,75 @@ +package featurestoreentityversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *FeaturestoreEntityVersionResource +} + +// CreateOrUpdate ... +func (c FeaturestoreEntityVersionClient) CreateOrUpdate(ctx context.Context, id FeatureStoreEntityVersionId, input FeaturestoreEntityVersionResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c FeaturestoreEntityVersionClient) CreateOrUpdateThenPoll(ctx context.Context, id FeatureStoreEntityVersionId, input FeaturestoreEntityVersionResource) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/method_delete.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/method_delete.go new file mode 100644 index 00000000000..3bf2551c8f9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/method_delete.go @@ -0,0 +1,71 @@ +package featurestoreentityversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 FeaturestoreEntityVersionClient) Delete(ctx context.Context, id FeatureStoreEntityVersionId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c FeaturestoreEntityVersionClient) DeleteThenPoll(ctx context.Context, id FeatureStoreEntityVersionId) 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/machinelearningservices/2025-04-01/featurestoreentityversion/method_get.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/method_get.go new file mode 100644 index 00000000000..ecee1aa0872 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/method_get.go @@ -0,0 +1,53 @@ +package featurestoreentityversion + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *FeaturestoreEntityVersionResource +} + +// Get ... +func (c FeaturestoreEntityVersionClient) Get(ctx context.Context, id FeatureStoreEntityVersionId) (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 FeaturestoreEntityVersionResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/method_list.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/method_list.go new file mode 100644 index 00000000000..6d748fbef97 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/method_list.go @@ -0,0 +1,166 @@ +package featurestoreentityversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]FeaturestoreEntityVersionResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []FeaturestoreEntityVersionResource +} + +type ListOperationOptions struct { + CreatedBy *string + Description *string + ListViewType *ListViewType + PageSize *int64 + Skip *string + Stage *string + Tags *string + Version *string + VersionName *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.CreatedBy != nil { + out.Append("createdBy", fmt.Sprintf("%v", *o.CreatedBy)) + } + if o.Description != nil { + out.Append("description", fmt.Sprintf("%v", *o.Description)) + } + if o.ListViewType != nil { + out.Append("listViewType", fmt.Sprintf("%v", *o.ListViewType)) + } + if o.PageSize != nil { + out.Append("pageSize", fmt.Sprintf("%v", *o.PageSize)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Stage != nil { + out.Append("stage", fmt.Sprintf("%v", *o.Stage)) + } + if o.Tags != nil { + out.Append("tags", fmt.Sprintf("%v", *o.Tags)) + } + if o.Version != nil { + out.Append("version", fmt.Sprintf("%v", *o.Version)) + } + if o.VersionName != nil { + out.Append("versionName", fmt.Sprintf("%v", *o.VersionName)) + } + 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 FeaturestoreEntityVersionClient) List(ctx context.Context, id FeatureStoreEntityId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/versions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]FeaturestoreEntityVersionResource `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 FeaturestoreEntityVersionClient) ListComplete(ctx context.Context, id FeatureStoreEntityId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, FeaturestoreEntityVersionResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c FeaturestoreEntityVersionClient) ListCompleteMatchingPredicate(ctx context.Context, id FeatureStoreEntityId, options ListOperationOptions, predicate FeaturestoreEntityVersionResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]FeaturestoreEntityVersionResource, 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/machinelearningservices/2025-04-01/featurestoreentityversion/model_featurestoreentityversion.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/model_featurestoreentityversion.go new file mode 100644 index 00000000000..452d0f7558c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/model_featurestoreentityversion.go @@ -0,0 +1,15 @@ +package featurestoreentityversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FeaturestoreEntityVersion struct { + Description *string `json:"description,omitempty"` + IndexColumns *[]IndexColumn `json:"indexColumns,omitempty"` + IsAnonymous *bool `json:"isAnonymous,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ProvisioningState *AssetProvisioningState `json:"provisioningState,omitempty"` + Stage *string `json:"stage,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/model_featurestoreentityversionresource.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/model_featurestoreentityversionresource.go new file mode 100644 index 00000000000..e35e45c6744 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/model_featurestoreentityversionresource.go @@ -0,0 +1,16 @@ +package featurestoreentityversion + +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 FeaturestoreEntityVersionResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties FeaturestoreEntityVersion `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/model_indexcolumn.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/model_indexcolumn.go new file mode 100644 index 00000000000..8e911cb2cc4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/model_indexcolumn.go @@ -0,0 +1,9 @@ +package featurestoreentityversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IndexColumn struct { + ColumnName *string `json:"columnName,omitempty"` + DataType *FeatureDataType `json:"dataType,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/predicates.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/predicates.go new file mode 100644 index 00000000000..bd6b5f3801e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/predicates.go @@ -0,0 +1,27 @@ +package featurestoreentityversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FeaturestoreEntityVersionResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p FeaturestoreEntityVersionResourceOperationPredicate) Matches(input FeaturestoreEntityVersionResource) 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/machinelearningservices/2025-04-01/featurestoreentityversion/version.go b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/version.go new file mode 100644 index 00000000000..49b848b42a8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/featurestoreentityversion/version.go @@ -0,0 +1,10 @@ +package featurestoreentityversion + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/featurestoreentityversion/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/README.md b/resource-manager/machinelearningservices/2025-04-01/job/README.md new file mode 100644 index 00000000000..35d2f2ad43b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/README.md @@ -0,0 +1,98 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/job` Documentation + +The `job` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/job" +``` + + +### Client Initialization + +```go +client := job.NewJobClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `JobClient.Cancel` + +```go +ctx := context.TODO() +id := job.NewJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "jobName") + +if err := client.CancelThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `JobClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := job.NewJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "jobName") + +payload := job.JobBaseResource{ + // ... +} + + +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: `JobClient.Delete` + +```go +ctx := context.TODO() +id := job.NewJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "jobName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `JobClient.Get` + +```go +ctx := context.TODO() +id := job.NewJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "jobName") + +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: `JobClient.List` + +```go +ctx := context.TODO() +id := job.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +// alternatively `client.List(ctx, id, job.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, job.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/job/client.go b/resource-manager/machinelearningservices/2025-04-01/job/client.go new file mode 100644 index 00000000000..7539b61a687 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/client.go @@ -0,0 +1,26 @@ +package job + +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 JobClient struct { + Client *resourcemanager.Client +} + +func NewJobClientWithBaseURI(sdkApi sdkEnv.Api) (*JobClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "job", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating JobClient: %+v", err) + } + + return &JobClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/constants.go b/resource-manager/machinelearningservices/2025-04-01/job/constants.go new file mode 100644 index 00000000000..01a1460a2a9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/constants.go @@ -0,0 +1,2262 @@ +package job + +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 BlockedTransformers string + +const ( + BlockedTransformersCatTargetEncoder BlockedTransformers = "CatTargetEncoder" + BlockedTransformersCountVectorizer BlockedTransformers = "CountVectorizer" + BlockedTransformersHashOneHotEncoder BlockedTransformers = "HashOneHotEncoder" + BlockedTransformersLabelEncoder BlockedTransformers = "LabelEncoder" + BlockedTransformersNaiveBayes BlockedTransformers = "NaiveBayes" + BlockedTransformersOneHotEncoder BlockedTransformers = "OneHotEncoder" + BlockedTransformersTextTargetEncoder BlockedTransformers = "TextTargetEncoder" + BlockedTransformersTfIdf BlockedTransformers = "TfIdf" + BlockedTransformersWoETargetEncoder BlockedTransformers = "WoETargetEncoder" + BlockedTransformersWordEmbedding BlockedTransformers = "WordEmbedding" +) + +func PossibleValuesForBlockedTransformers() []string { + return []string{ + string(BlockedTransformersCatTargetEncoder), + string(BlockedTransformersCountVectorizer), + string(BlockedTransformersHashOneHotEncoder), + string(BlockedTransformersLabelEncoder), + string(BlockedTransformersNaiveBayes), + string(BlockedTransformersOneHotEncoder), + string(BlockedTransformersTextTargetEncoder), + string(BlockedTransformersTfIdf), + string(BlockedTransformersWoETargetEncoder), + string(BlockedTransformersWordEmbedding), + } +} + +func (s *BlockedTransformers) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBlockedTransformers(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBlockedTransformers(input string) (*BlockedTransformers, error) { + vals := map[string]BlockedTransformers{ + "cattargetencoder": BlockedTransformersCatTargetEncoder, + "countvectorizer": BlockedTransformersCountVectorizer, + "hashonehotencoder": BlockedTransformersHashOneHotEncoder, + "labelencoder": BlockedTransformersLabelEncoder, + "naivebayes": BlockedTransformersNaiveBayes, + "onehotencoder": BlockedTransformersOneHotEncoder, + "texttargetencoder": BlockedTransformersTextTargetEncoder, + "tfidf": BlockedTransformersTfIdf, + "woetargetencoder": BlockedTransformersWoETargetEncoder, + "wordembedding": BlockedTransformersWordEmbedding, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BlockedTransformers(input) + return &out, nil +} + +type ClassificationModels string + +const ( + ClassificationModelsBernoulliNaiveBayes ClassificationModels = "BernoulliNaiveBayes" + ClassificationModelsDecisionTree ClassificationModels = "DecisionTree" + ClassificationModelsExtremeRandomTrees ClassificationModels = "ExtremeRandomTrees" + ClassificationModelsGradientBoosting ClassificationModels = "GradientBoosting" + ClassificationModelsKNN ClassificationModels = "KNN" + ClassificationModelsLightGBM ClassificationModels = "LightGBM" + ClassificationModelsLinearSVM ClassificationModels = "LinearSVM" + ClassificationModelsLogisticRegression ClassificationModels = "LogisticRegression" + ClassificationModelsMultinomialNaiveBayes ClassificationModels = "MultinomialNaiveBayes" + ClassificationModelsRandomForest ClassificationModels = "RandomForest" + ClassificationModelsSGD ClassificationModels = "SGD" + ClassificationModelsSVM ClassificationModels = "SVM" + ClassificationModelsXGBoostClassifier ClassificationModels = "XGBoostClassifier" +) + +func PossibleValuesForClassificationModels() []string { + return []string{ + string(ClassificationModelsBernoulliNaiveBayes), + string(ClassificationModelsDecisionTree), + string(ClassificationModelsExtremeRandomTrees), + string(ClassificationModelsGradientBoosting), + string(ClassificationModelsKNN), + string(ClassificationModelsLightGBM), + string(ClassificationModelsLinearSVM), + string(ClassificationModelsLogisticRegression), + string(ClassificationModelsMultinomialNaiveBayes), + string(ClassificationModelsRandomForest), + string(ClassificationModelsSGD), + string(ClassificationModelsSVM), + string(ClassificationModelsXGBoostClassifier), + } +} + +func (s *ClassificationModels) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClassificationModels(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClassificationModels(input string) (*ClassificationModels, error) { + vals := map[string]ClassificationModels{ + "bernoullinaivebayes": ClassificationModelsBernoulliNaiveBayes, + "decisiontree": ClassificationModelsDecisionTree, + "extremerandomtrees": ClassificationModelsExtremeRandomTrees, + "gradientboosting": ClassificationModelsGradientBoosting, + "knn": ClassificationModelsKNN, + "lightgbm": ClassificationModelsLightGBM, + "linearsvm": ClassificationModelsLinearSVM, + "logisticregression": ClassificationModelsLogisticRegression, + "multinomialnaivebayes": ClassificationModelsMultinomialNaiveBayes, + "randomforest": ClassificationModelsRandomForest, + "sgd": ClassificationModelsSGD, + "svm": ClassificationModelsSVM, + "xgboostclassifier": ClassificationModelsXGBoostClassifier, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClassificationModels(input) + return &out, nil +} + +type ClassificationMultilabelPrimaryMetrics string + +const ( + ClassificationMultilabelPrimaryMetricsAUCWeighted ClassificationMultilabelPrimaryMetrics = "AUCWeighted" + ClassificationMultilabelPrimaryMetricsAccuracy ClassificationMultilabelPrimaryMetrics = "Accuracy" + ClassificationMultilabelPrimaryMetricsAveragePrecisionScoreWeighted ClassificationMultilabelPrimaryMetrics = "AveragePrecisionScoreWeighted" + ClassificationMultilabelPrimaryMetricsIOU ClassificationMultilabelPrimaryMetrics = "IOU" + ClassificationMultilabelPrimaryMetricsNormMacroRecall ClassificationMultilabelPrimaryMetrics = "NormMacroRecall" + ClassificationMultilabelPrimaryMetricsPrecisionScoreWeighted ClassificationMultilabelPrimaryMetrics = "PrecisionScoreWeighted" +) + +func PossibleValuesForClassificationMultilabelPrimaryMetrics() []string { + return []string{ + string(ClassificationMultilabelPrimaryMetricsAUCWeighted), + string(ClassificationMultilabelPrimaryMetricsAccuracy), + string(ClassificationMultilabelPrimaryMetricsAveragePrecisionScoreWeighted), + string(ClassificationMultilabelPrimaryMetricsIOU), + string(ClassificationMultilabelPrimaryMetricsNormMacroRecall), + string(ClassificationMultilabelPrimaryMetricsPrecisionScoreWeighted), + } +} + +func (s *ClassificationMultilabelPrimaryMetrics) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClassificationMultilabelPrimaryMetrics(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClassificationMultilabelPrimaryMetrics(input string) (*ClassificationMultilabelPrimaryMetrics, error) { + vals := map[string]ClassificationMultilabelPrimaryMetrics{ + "aucweighted": ClassificationMultilabelPrimaryMetricsAUCWeighted, + "accuracy": ClassificationMultilabelPrimaryMetricsAccuracy, + "averageprecisionscoreweighted": ClassificationMultilabelPrimaryMetricsAveragePrecisionScoreWeighted, + "iou": ClassificationMultilabelPrimaryMetricsIOU, + "normmacrorecall": ClassificationMultilabelPrimaryMetricsNormMacroRecall, + "precisionscoreweighted": ClassificationMultilabelPrimaryMetricsPrecisionScoreWeighted, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClassificationMultilabelPrimaryMetrics(input) + return &out, nil +} + +type ClassificationPrimaryMetrics string + +const ( + ClassificationPrimaryMetricsAUCWeighted ClassificationPrimaryMetrics = "AUCWeighted" + ClassificationPrimaryMetricsAccuracy ClassificationPrimaryMetrics = "Accuracy" + ClassificationPrimaryMetricsAveragePrecisionScoreWeighted ClassificationPrimaryMetrics = "AveragePrecisionScoreWeighted" + ClassificationPrimaryMetricsNormMacroRecall ClassificationPrimaryMetrics = "NormMacroRecall" + ClassificationPrimaryMetricsPrecisionScoreWeighted ClassificationPrimaryMetrics = "PrecisionScoreWeighted" +) + +func PossibleValuesForClassificationPrimaryMetrics() []string { + return []string{ + string(ClassificationPrimaryMetricsAUCWeighted), + string(ClassificationPrimaryMetricsAccuracy), + string(ClassificationPrimaryMetricsAveragePrecisionScoreWeighted), + string(ClassificationPrimaryMetricsNormMacroRecall), + string(ClassificationPrimaryMetricsPrecisionScoreWeighted), + } +} + +func (s *ClassificationPrimaryMetrics) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClassificationPrimaryMetrics(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClassificationPrimaryMetrics(input string) (*ClassificationPrimaryMetrics, error) { + vals := map[string]ClassificationPrimaryMetrics{ + "aucweighted": ClassificationPrimaryMetricsAUCWeighted, + "accuracy": ClassificationPrimaryMetricsAccuracy, + "averageprecisionscoreweighted": ClassificationPrimaryMetricsAveragePrecisionScoreWeighted, + "normmacrorecall": ClassificationPrimaryMetricsNormMacroRecall, + "precisionscoreweighted": ClassificationPrimaryMetricsPrecisionScoreWeighted, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClassificationPrimaryMetrics(input) + return &out, nil +} + +type DistributionType string + +const ( + DistributionTypeMpi DistributionType = "Mpi" + DistributionTypePyTorch DistributionType = "PyTorch" + DistributionTypeTensorFlow DistributionType = "TensorFlow" +) + +func PossibleValuesForDistributionType() []string { + return []string{ + string(DistributionTypeMpi), + string(DistributionTypePyTorch), + string(DistributionTypeTensorFlow), + } +} + +func (s *DistributionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDistributionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDistributionType(input string) (*DistributionType, error) { + vals := map[string]DistributionType{ + "mpi": DistributionTypeMpi, + "pytorch": DistributionTypePyTorch, + "tensorflow": DistributionTypeTensorFlow, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DistributionType(input) + return &out, nil +} + +type EarlyTerminationPolicyType string + +const ( + EarlyTerminationPolicyTypeBandit EarlyTerminationPolicyType = "Bandit" + EarlyTerminationPolicyTypeMedianStopping EarlyTerminationPolicyType = "MedianStopping" + EarlyTerminationPolicyTypeTruncationSelection EarlyTerminationPolicyType = "TruncationSelection" +) + +func PossibleValuesForEarlyTerminationPolicyType() []string { + return []string{ + string(EarlyTerminationPolicyTypeBandit), + string(EarlyTerminationPolicyTypeMedianStopping), + string(EarlyTerminationPolicyTypeTruncationSelection), + } +} + +func (s *EarlyTerminationPolicyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEarlyTerminationPolicyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEarlyTerminationPolicyType(input string) (*EarlyTerminationPolicyType, error) { + vals := map[string]EarlyTerminationPolicyType{ + "bandit": EarlyTerminationPolicyTypeBandit, + "medianstopping": EarlyTerminationPolicyTypeMedianStopping, + "truncationselection": EarlyTerminationPolicyTypeTruncationSelection, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EarlyTerminationPolicyType(input) + return &out, nil +} + +type EmailNotificationEnableType string + +const ( + EmailNotificationEnableTypeJobCancelled EmailNotificationEnableType = "JobCancelled" + EmailNotificationEnableTypeJobCompleted EmailNotificationEnableType = "JobCompleted" + EmailNotificationEnableTypeJobFailed EmailNotificationEnableType = "JobFailed" +) + +func PossibleValuesForEmailNotificationEnableType() []string { + return []string{ + string(EmailNotificationEnableTypeJobCancelled), + string(EmailNotificationEnableTypeJobCompleted), + string(EmailNotificationEnableTypeJobFailed), + } +} + +func (s *EmailNotificationEnableType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEmailNotificationEnableType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEmailNotificationEnableType(input string) (*EmailNotificationEnableType, error) { + vals := map[string]EmailNotificationEnableType{ + "jobcancelled": EmailNotificationEnableTypeJobCancelled, + "jobcompleted": EmailNotificationEnableTypeJobCompleted, + "jobfailed": EmailNotificationEnableTypeJobFailed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EmailNotificationEnableType(input) + return &out, nil +} + +type FeatureLags string + +const ( + FeatureLagsAuto FeatureLags = "Auto" + FeatureLagsNone FeatureLags = "None" +) + +func PossibleValuesForFeatureLags() []string { + return []string{ + string(FeatureLagsAuto), + string(FeatureLagsNone), + } +} + +func (s *FeatureLags) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFeatureLags(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFeatureLags(input string) (*FeatureLags, error) { + vals := map[string]FeatureLags{ + "auto": FeatureLagsAuto, + "none": FeatureLagsNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FeatureLags(input) + return &out, nil +} + +type FeaturizationMode string + +const ( + FeaturizationModeAuto FeaturizationMode = "Auto" + FeaturizationModeCustom FeaturizationMode = "Custom" + FeaturizationModeOff FeaturizationMode = "Off" +) + +func PossibleValuesForFeaturizationMode() []string { + return []string{ + string(FeaturizationModeAuto), + string(FeaturizationModeCustom), + string(FeaturizationModeOff), + } +} + +func (s *FeaturizationMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFeaturizationMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFeaturizationMode(input string) (*FeaturizationMode, error) { + vals := map[string]FeaturizationMode{ + "auto": FeaturizationModeAuto, + "custom": FeaturizationModeCustom, + "off": FeaturizationModeOff, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FeaturizationMode(input) + return &out, nil +} + +type ForecastHorizonMode string + +const ( + ForecastHorizonModeAuto ForecastHorizonMode = "Auto" + ForecastHorizonModeCustom ForecastHorizonMode = "Custom" +) + +func PossibleValuesForForecastHorizonMode() []string { + return []string{ + string(ForecastHorizonModeAuto), + string(ForecastHorizonModeCustom), + } +} + +func (s *ForecastHorizonMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseForecastHorizonMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseForecastHorizonMode(input string) (*ForecastHorizonMode, error) { + vals := map[string]ForecastHorizonMode{ + "auto": ForecastHorizonModeAuto, + "custom": ForecastHorizonModeCustom, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ForecastHorizonMode(input) + return &out, nil +} + +type ForecastingModels string + +const ( + ForecastingModelsArimax ForecastingModels = "Arimax" + ForecastingModelsAutoArima ForecastingModels = "AutoArima" + ForecastingModelsAverage ForecastingModels = "Average" + ForecastingModelsDecisionTree ForecastingModels = "DecisionTree" + ForecastingModelsElasticNet ForecastingModels = "ElasticNet" + ForecastingModelsExponentialSmoothing ForecastingModels = "ExponentialSmoothing" + ForecastingModelsExtremeRandomTrees ForecastingModels = "ExtremeRandomTrees" + ForecastingModelsGradientBoosting ForecastingModels = "GradientBoosting" + ForecastingModelsKNN ForecastingModels = "KNN" + ForecastingModelsLassoLars ForecastingModels = "LassoLars" + ForecastingModelsLightGBM ForecastingModels = "LightGBM" + ForecastingModelsNaive ForecastingModels = "Naive" + ForecastingModelsProphet ForecastingModels = "Prophet" + ForecastingModelsRandomForest ForecastingModels = "RandomForest" + ForecastingModelsSGD ForecastingModels = "SGD" + ForecastingModelsSeasonalAverage ForecastingModels = "SeasonalAverage" + ForecastingModelsSeasonalNaive ForecastingModels = "SeasonalNaive" + ForecastingModelsTCNForecaster ForecastingModels = "TCNForecaster" + ForecastingModelsXGBoostRegressor ForecastingModels = "XGBoostRegressor" +) + +func PossibleValuesForForecastingModels() []string { + return []string{ + string(ForecastingModelsArimax), + string(ForecastingModelsAutoArima), + string(ForecastingModelsAverage), + string(ForecastingModelsDecisionTree), + string(ForecastingModelsElasticNet), + string(ForecastingModelsExponentialSmoothing), + string(ForecastingModelsExtremeRandomTrees), + string(ForecastingModelsGradientBoosting), + string(ForecastingModelsKNN), + string(ForecastingModelsLassoLars), + string(ForecastingModelsLightGBM), + string(ForecastingModelsNaive), + string(ForecastingModelsProphet), + string(ForecastingModelsRandomForest), + string(ForecastingModelsSGD), + string(ForecastingModelsSeasonalAverage), + string(ForecastingModelsSeasonalNaive), + string(ForecastingModelsTCNForecaster), + string(ForecastingModelsXGBoostRegressor), + } +} + +func (s *ForecastingModels) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseForecastingModels(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseForecastingModels(input string) (*ForecastingModels, error) { + vals := map[string]ForecastingModels{ + "arimax": ForecastingModelsArimax, + "autoarima": ForecastingModelsAutoArima, + "average": ForecastingModelsAverage, + "decisiontree": ForecastingModelsDecisionTree, + "elasticnet": ForecastingModelsElasticNet, + "exponentialsmoothing": ForecastingModelsExponentialSmoothing, + "extremerandomtrees": ForecastingModelsExtremeRandomTrees, + "gradientboosting": ForecastingModelsGradientBoosting, + "knn": ForecastingModelsKNN, + "lassolars": ForecastingModelsLassoLars, + "lightgbm": ForecastingModelsLightGBM, + "naive": ForecastingModelsNaive, + "prophet": ForecastingModelsProphet, + "randomforest": ForecastingModelsRandomForest, + "sgd": ForecastingModelsSGD, + "seasonalaverage": ForecastingModelsSeasonalAverage, + "seasonalnaive": ForecastingModelsSeasonalNaive, + "tcnforecaster": ForecastingModelsTCNForecaster, + "xgboostregressor": ForecastingModelsXGBoostRegressor, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ForecastingModels(input) + return &out, nil +} + +type ForecastingPrimaryMetrics string + +const ( + ForecastingPrimaryMetricsNormalizedMeanAbsoluteError ForecastingPrimaryMetrics = "NormalizedMeanAbsoluteError" + ForecastingPrimaryMetricsNormalizedRootMeanSquaredError ForecastingPrimaryMetrics = "NormalizedRootMeanSquaredError" + ForecastingPrimaryMetricsRTwoScore ForecastingPrimaryMetrics = "R2Score" + ForecastingPrimaryMetricsSpearmanCorrelation ForecastingPrimaryMetrics = "SpearmanCorrelation" +) + +func PossibleValuesForForecastingPrimaryMetrics() []string { + return []string{ + string(ForecastingPrimaryMetricsNormalizedMeanAbsoluteError), + string(ForecastingPrimaryMetricsNormalizedRootMeanSquaredError), + string(ForecastingPrimaryMetricsRTwoScore), + string(ForecastingPrimaryMetricsSpearmanCorrelation), + } +} + +func (s *ForecastingPrimaryMetrics) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseForecastingPrimaryMetrics(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseForecastingPrimaryMetrics(input string) (*ForecastingPrimaryMetrics, error) { + vals := map[string]ForecastingPrimaryMetrics{ + "normalizedmeanabsoluteerror": ForecastingPrimaryMetricsNormalizedMeanAbsoluteError, + "normalizedrootmeansquarederror": ForecastingPrimaryMetricsNormalizedRootMeanSquaredError, + "r2score": ForecastingPrimaryMetricsRTwoScore, + "spearmancorrelation": ForecastingPrimaryMetricsSpearmanCorrelation, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ForecastingPrimaryMetrics(input) + return &out, nil +} + +type Goal string + +const ( + GoalMaximize Goal = "Maximize" + GoalMinimize Goal = "Minimize" +) + +func PossibleValuesForGoal() []string { + return []string{ + string(GoalMaximize), + string(GoalMinimize), + } +} + +func (s *Goal) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGoal(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGoal(input string) (*Goal, error) { + vals := map[string]Goal{ + "maximize": GoalMaximize, + "minimize": GoalMinimize, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Goal(input) + return &out, nil +} + +type IdentityConfigurationType string + +const ( + IdentityConfigurationTypeAMLToken IdentityConfigurationType = "AMLToken" + IdentityConfigurationTypeManaged IdentityConfigurationType = "Managed" + IdentityConfigurationTypeUserIdentity IdentityConfigurationType = "UserIdentity" +) + +func PossibleValuesForIdentityConfigurationType() []string { + return []string{ + string(IdentityConfigurationTypeAMLToken), + string(IdentityConfigurationTypeManaged), + string(IdentityConfigurationTypeUserIdentity), + } +} + +func (s *IdentityConfigurationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIdentityConfigurationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIdentityConfigurationType(input string) (*IdentityConfigurationType, error) { + vals := map[string]IdentityConfigurationType{ + "amltoken": IdentityConfigurationTypeAMLToken, + "managed": IdentityConfigurationTypeManaged, + "useridentity": IdentityConfigurationTypeUserIdentity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IdentityConfigurationType(input) + return &out, nil +} + +type InputDeliveryMode string + +const ( + InputDeliveryModeDirect InputDeliveryMode = "Direct" + InputDeliveryModeDownload InputDeliveryMode = "Download" + InputDeliveryModeEvalDownload InputDeliveryMode = "EvalDownload" + InputDeliveryModeEvalMount InputDeliveryMode = "EvalMount" + InputDeliveryModeReadOnlyMount InputDeliveryMode = "ReadOnlyMount" + InputDeliveryModeReadWriteMount InputDeliveryMode = "ReadWriteMount" +) + +func PossibleValuesForInputDeliveryMode() []string { + return []string{ + string(InputDeliveryModeDirect), + string(InputDeliveryModeDownload), + string(InputDeliveryModeEvalDownload), + string(InputDeliveryModeEvalMount), + string(InputDeliveryModeReadOnlyMount), + string(InputDeliveryModeReadWriteMount), + } +} + +func (s *InputDeliveryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInputDeliveryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInputDeliveryMode(input string) (*InputDeliveryMode, error) { + vals := map[string]InputDeliveryMode{ + "direct": InputDeliveryModeDirect, + "download": InputDeliveryModeDownload, + "evaldownload": InputDeliveryModeEvalDownload, + "evalmount": InputDeliveryModeEvalMount, + "readonlymount": InputDeliveryModeReadOnlyMount, + "readwritemount": InputDeliveryModeReadWriteMount, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InputDeliveryMode(input) + return &out, nil +} + +type InstanceSegmentationPrimaryMetrics string + +const ( + InstanceSegmentationPrimaryMetricsMeanAveragePrecision InstanceSegmentationPrimaryMetrics = "MeanAveragePrecision" +) + +func PossibleValuesForInstanceSegmentationPrimaryMetrics() []string { + return []string{ + string(InstanceSegmentationPrimaryMetricsMeanAveragePrecision), + } +} + +func (s *InstanceSegmentationPrimaryMetrics) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInstanceSegmentationPrimaryMetrics(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInstanceSegmentationPrimaryMetrics(input string) (*InstanceSegmentationPrimaryMetrics, error) { + vals := map[string]InstanceSegmentationPrimaryMetrics{ + "meanaverageprecision": InstanceSegmentationPrimaryMetricsMeanAveragePrecision, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InstanceSegmentationPrimaryMetrics(input) + return &out, nil +} + +type JobInputType string + +const ( + JobInputTypeCustomModel JobInputType = "custom_model" + JobInputTypeLiteral JobInputType = "literal" + JobInputTypeMlflowModel JobInputType = "mlflow_model" + JobInputTypeMltable JobInputType = "mltable" + JobInputTypeTritonModel JobInputType = "triton_model" + JobInputTypeUriFile JobInputType = "uri_file" + JobInputTypeUriFolder JobInputType = "uri_folder" +) + +func PossibleValuesForJobInputType() []string { + return []string{ + string(JobInputTypeCustomModel), + string(JobInputTypeLiteral), + string(JobInputTypeMlflowModel), + string(JobInputTypeMltable), + string(JobInputTypeTritonModel), + string(JobInputTypeUriFile), + string(JobInputTypeUriFolder), + } +} + +func (s *JobInputType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseJobInputType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseJobInputType(input string) (*JobInputType, error) { + vals := map[string]JobInputType{ + "custom_model": JobInputTypeCustomModel, + "literal": JobInputTypeLiteral, + "mlflow_model": JobInputTypeMlflowModel, + "mltable": JobInputTypeMltable, + "triton_model": JobInputTypeTritonModel, + "uri_file": JobInputTypeUriFile, + "uri_folder": JobInputTypeUriFolder, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := JobInputType(input) + return &out, nil +} + +type JobLimitsType string + +const ( + JobLimitsTypeCommand JobLimitsType = "Command" + JobLimitsTypeSweep JobLimitsType = "Sweep" +) + +func PossibleValuesForJobLimitsType() []string { + return []string{ + string(JobLimitsTypeCommand), + string(JobLimitsTypeSweep), + } +} + +func (s *JobLimitsType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseJobLimitsType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseJobLimitsType(input string) (*JobLimitsType, error) { + vals := map[string]JobLimitsType{ + "command": JobLimitsTypeCommand, + "sweep": JobLimitsTypeSweep, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := JobLimitsType(input) + return &out, nil +} + +type JobOutputType string + +const ( + JobOutputTypeCustomModel JobOutputType = "custom_model" + JobOutputTypeMlflowModel JobOutputType = "mlflow_model" + JobOutputTypeMltable JobOutputType = "mltable" + JobOutputTypeTritonModel JobOutputType = "triton_model" + JobOutputTypeUriFile JobOutputType = "uri_file" + JobOutputTypeUriFolder JobOutputType = "uri_folder" +) + +func PossibleValuesForJobOutputType() []string { + return []string{ + string(JobOutputTypeCustomModel), + string(JobOutputTypeMlflowModel), + string(JobOutputTypeMltable), + string(JobOutputTypeTritonModel), + string(JobOutputTypeUriFile), + string(JobOutputTypeUriFolder), + } +} + +func (s *JobOutputType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseJobOutputType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseJobOutputType(input string) (*JobOutputType, error) { + vals := map[string]JobOutputType{ + "custom_model": JobOutputTypeCustomModel, + "mlflow_model": JobOutputTypeMlflowModel, + "mltable": JobOutputTypeMltable, + "triton_model": JobOutputTypeTritonModel, + "uri_file": JobOutputTypeUriFile, + "uri_folder": JobOutputTypeUriFolder, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := JobOutputType(input) + return &out, nil +} + +type JobStatus string + +const ( + JobStatusCancelRequested JobStatus = "CancelRequested" + JobStatusCanceled JobStatus = "Canceled" + JobStatusCompleted JobStatus = "Completed" + JobStatusFailed JobStatus = "Failed" + JobStatusFinalizing JobStatus = "Finalizing" + JobStatusNotResponding JobStatus = "NotResponding" + JobStatusNotStarted JobStatus = "NotStarted" + JobStatusPaused JobStatus = "Paused" + JobStatusPreparing JobStatus = "Preparing" + JobStatusProvisioning JobStatus = "Provisioning" + JobStatusQueued JobStatus = "Queued" + JobStatusRunning JobStatus = "Running" + JobStatusStarting JobStatus = "Starting" + JobStatusUnknown JobStatus = "Unknown" +) + +func PossibleValuesForJobStatus() []string { + return []string{ + string(JobStatusCancelRequested), + string(JobStatusCanceled), + string(JobStatusCompleted), + string(JobStatusFailed), + string(JobStatusFinalizing), + string(JobStatusNotResponding), + string(JobStatusNotStarted), + string(JobStatusPaused), + string(JobStatusPreparing), + string(JobStatusProvisioning), + string(JobStatusQueued), + string(JobStatusRunning), + string(JobStatusStarting), + string(JobStatusUnknown), + } +} + +func (s *JobStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseJobStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseJobStatus(input string) (*JobStatus, error) { + vals := map[string]JobStatus{ + "cancelrequested": JobStatusCancelRequested, + "canceled": JobStatusCanceled, + "completed": JobStatusCompleted, + "failed": JobStatusFailed, + "finalizing": JobStatusFinalizing, + "notresponding": JobStatusNotResponding, + "notstarted": JobStatusNotStarted, + "paused": JobStatusPaused, + "preparing": JobStatusPreparing, + "provisioning": JobStatusProvisioning, + "queued": JobStatusQueued, + "running": JobStatusRunning, + "starting": JobStatusStarting, + "unknown": JobStatusUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := JobStatus(input) + return &out, nil +} + +type JobTier string + +const ( + JobTierBasic JobTier = "Basic" + JobTierNull JobTier = "Null" + JobTierPremium JobTier = "Premium" + JobTierSpot JobTier = "Spot" + JobTierStandard JobTier = "Standard" +) + +func PossibleValuesForJobTier() []string { + return []string{ + string(JobTierBasic), + string(JobTierNull), + string(JobTierPremium), + string(JobTierSpot), + string(JobTierStandard), + } +} + +func (s *JobTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseJobTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseJobTier(input string) (*JobTier, error) { + vals := map[string]JobTier{ + "basic": JobTierBasic, + "null": JobTierNull, + "premium": JobTierPremium, + "spot": JobTierSpot, + "standard": JobTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := JobTier(input) + return &out, nil +} + +type JobType string + +const ( + JobTypeAutoML JobType = "AutoML" + JobTypeCommand JobType = "Command" + JobTypePipeline JobType = "Pipeline" + JobTypeSpark JobType = "Spark" + JobTypeSweep JobType = "Sweep" +) + +func PossibleValuesForJobType() []string { + return []string{ + string(JobTypeAutoML), + string(JobTypeCommand), + string(JobTypePipeline), + string(JobTypeSpark), + string(JobTypeSweep), + } +} + +func (s *JobType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseJobType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseJobType(input string) (*JobType, error) { + vals := map[string]JobType{ + "automl": JobTypeAutoML, + "command": JobTypeCommand, + "pipeline": JobTypePipeline, + "spark": JobTypeSpark, + "sweep": JobTypeSweep, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := JobType(input) + return &out, nil +} + +type LearningRateScheduler string + +const ( + LearningRateSchedulerNone LearningRateScheduler = "None" + LearningRateSchedulerStep LearningRateScheduler = "Step" + LearningRateSchedulerWarmupCosine LearningRateScheduler = "WarmupCosine" +) + +func PossibleValuesForLearningRateScheduler() []string { + return []string{ + string(LearningRateSchedulerNone), + string(LearningRateSchedulerStep), + string(LearningRateSchedulerWarmupCosine), + } +} + +func (s *LearningRateScheduler) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLearningRateScheduler(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLearningRateScheduler(input string) (*LearningRateScheduler, error) { + vals := map[string]LearningRateScheduler{ + "none": LearningRateSchedulerNone, + "step": LearningRateSchedulerStep, + "warmupcosine": LearningRateSchedulerWarmupCosine, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LearningRateScheduler(input) + return &out, nil +} + +type ListViewType string + +const ( + ListViewTypeActiveOnly ListViewType = "ActiveOnly" + ListViewTypeAll ListViewType = "All" + ListViewTypeArchivedOnly ListViewType = "ArchivedOnly" +) + +func PossibleValuesForListViewType() []string { + return []string{ + string(ListViewTypeActiveOnly), + string(ListViewTypeAll), + string(ListViewTypeArchivedOnly), + } +} + +func (s *ListViewType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseListViewType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseListViewType(input string) (*ListViewType, error) { + vals := map[string]ListViewType{ + "activeonly": ListViewTypeActiveOnly, + "all": ListViewTypeAll, + "archivedonly": ListViewTypeArchivedOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ListViewType(input) + return &out, nil +} + +type LogVerbosity string + +const ( + LogVerbosityCritical LogVerbosity = "Critical" + LogVerbosityDebug LogVerbosity = "Debug" + LogVerbosityError LogVerbosity = "Error" + LogVerbosityInfo LogVerbosity = "Info" + LogVerbosityNotSet LogVerbosity = "NotSet" + LogVerbosityWarning LogVerbosity = "Warning" +) + +func PossibleValuesForLogVerbosity() []string { + return []string{ + string(LogVerbosityCritical), + string(LogVerbosityDebug), + string(LogVerbosityError), + string(LogVerbosityInfo), + string(LogVerbosityNotSet), + string(LogVerbosityWarning), + } +} + +func (s *LogVerbosity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLogVerbosity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLogVerbosity(input string) (*LogVerbosity, error) { + vals := map[string]LogVerbosity{ + "critical": LogVerbosityCritical, + "debug": LogVerbosityDebug, + "error": LogVerbosityError, + "info": LogVerbosityInfo, + "notset": LogVerbosityNotSet, + "warning": LogVerbosityWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LogVerbosity(input) + return &out, nil +} + +type ModelSize string + +const ( + ModelSizeExtraLarge ModelSize = "ExtraLarge" + ModelSizeLarge ModelSize = "Large" + ModelSizeMedium ModelSize = "Medium" + ModelSizeNone ModelSize = "None" + ModelSizeSmall ModelSize = "Small" +) + +func PossibleValuesForModelSize() []string { + return []string{ + string(ModelSizeExtraLarge), + string(ModelSizeLarge), + string(ModelSizeMedium), + string(ModelSizeNone), + string(ModelSizeSmall), + } +} + +func (s *ModelSize) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseModelSize(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseModelSize(input string) (*ModelSize, error) { + vals := map[string]ModelSize{ + "extralarge": ModelSizeExtraLarge, + "large": ModelSizeLarge, + "medium": ModelSizeMedium, + "none": ModelSizeNone, + "small": ModelSizeSmall, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ModelSize(input) + return &out, nil +} + +type NCrossValidationsMode string + +const ( + NCrossValidationsModeAuto NCrossValidationsMode = "Auto" + NCrossValidationsModeCustom NCrossValidationsMode = "Custom" +) + +func PossibleValuesForNCrossValidationsMode() []string { + return []string{ + string(NCrossValidationsModeAuto), + string(NCrossValidationsModeCustom), + } +} + +func (s *NCrossValidationsMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNCrossValidationsMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNCrossValidationsMode(input string) (*NCrossValidationsMode, error) { + vals := map[string]NCrossValidationsMode{ + "auto": NCrossValidationsModeAuto, + "custom": NCrossValidationsModeCustom, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NCrossValidationsMode(input) + return &out, nil +} + +type NodesValueType string + +const ( + NodesValueTypeAll NodesValueType = "All" +) + +func PossibleValuesForNodesValueType() []string { + return []string{ + string(NodesValueTypeAll), + } +} + +func (s *NodesValueType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNodesValueType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNodesValueType(input string) (*NodesValueType, error) { + vals := map[string]NodesValueType{ + "all": NodesValueTypeAll, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NodesValueType(input) + return &out, nil +} + +type ObjectDetectionPrimaryMetrics string + +const ( + ObjectDetectionPrimaryMetricsMeanAveragePrecision ObjectDetectionPrimaryMetrics = "MeanAveragePrecision" +) + +func PossibleValuesForObjectDetectionPrimaryMetrics() []string { + return []string{ + string(ObjectDetectionPrimaryMetricsMeanAveragePrecision), + } +} + +func (s *ObjectDetectionPrimaryMetrics) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseObjectDetectionPrimaryMetrics(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseObjectDetectionPrimaryMetrics(input string) (*ObjectDetectionPrimaryMetrics, error) { + vals := map[string]ObjectDetectionPrimaryMetrics{ + "meanaverageprecision": ObjectDetectionPrimaryMetricsMeanAveragePrecision, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ObjectDetectionPrimaryMetrics(input) + return &out, nil +} + +type OutputDeliveryMode string + +const ( + OutputDeliveryModeDirect OutputDeliveryMode = "Direct" + OutputDeliveryModeReadWriteMount OutputDeliveryMode = "ReadWriteMount" + OutputDeliveryModeUpload OutputDeliveryMode = "Upload" +) + +func PossibleValuesForOutputDeliveryMode() []string { + return []string{ + string(OutputDeliveryModeDirect), + string(OutputDeliveryModeReadWriteMount), + string(OutputDeliveryModeUpload), + } +} + +func (s *OutputDeliveryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOutputDeliveryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOutputDeliveryMode(input string) (*OutputDeliveryMode, error) { + vals := map[string]OutputDeliveryMode{ + "direct": OutputDeliveryModeDirect, + "readwritemount": OutputDeliveryModeReadWriteMount, + "upload": OutputDeliveryModeUpload, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OutputDeliveryMode(input) + return &out, nil +} + +type RandomSamplingAlgorithmRule string + +const ( + RandomSamplingAlgorithmRuleRandom RandomSamplingAlgorithmRule = "Random" + RandomSamplingAlgorithmRuleSobol RandomSamplingAlgorithmRule = "Sobol" +) + +func PossibleValuesForRandomSamplingAlgorithmRule() []string { + return []string{ + string(RandomSamplingAlgorithmRuleRandom), + string(RandomSamplingAlgorithmRuleSobol), + } +} + +func (s *RandomSamplingAlgorithmRule) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRandomSamplingAlgorithmRule(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRandomSamplingAlgorithmRule(input string) (*RandomSamplingAlgorithmRule, error) { + vals := map[string]RandomSamplingAlgorithmRule{ + "random": RandomSamplingAlgorithmRuleRandom, + "sobol": RandomSamplingAlgorithmRuleSobol, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RandomSamplingAlgorithmRule(input) + return &out, nil +} + +type RegressionModels string + +const ( + RegressionModelsDecisionTree RegressionModels = "DecisionTree" + RegressionModelsElasticNet RegressionModels = "ElasticNet" + RegressionModelsExtremeRandomTrees RegressionModels = "ExtremeRandomTrees" + RegressionModelsGradientBoosting RegressionModels = "GradientBoosting" + RegressionModelsKNN RegressionModels = "KNN" + RegressionModelsLassoLars RegressionModels = "LassoLars" + RegressionModelsLightGBM RegressionModels = "LightGBM" + RegressionModelsRandomForest RegressionModels = "RandomForest" + RegressionModelsSGD RegressionModels = "SGD" + RegressionModelsXGBoostRegressor RegressionModels = "XGBoostRegressor" +) + +func PossibleValuesForRegressionModels() []string { + return []string{ + string(RegressionModelsDecisionTree), + string(RegressionModelsElasticNet), + string(RegressionModelsExtremeRandomTrees), + string(RegressionModelsGradientBoosting), + string(RegressionModelsKNN), + string(RegressionModelsLassoLars), + string(RegressionModelsLightGBM), + string(RegressionModelsRandomForest), + string(RegressionModelsSGD), + string(RegressionModelsXGBoostRegressor), + } +} + +func (s *RegressionModels) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRegressionModels(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRegressionModels(input string) (*RegressionModels, error) { + vals := map[string]RegressionModels{ + "decisiontree": RegressionModelsDecisionTree, + "elasticnet": RegressionModelsElasticNet, + "extremerandomtrees": RegressionModelsExtremeRandomTrees, + "gradientboosting": RegressionModelsGradientBoosting, + "knn": RegressionModelsKNN, + "lassolars": RegressionModelsLassoLars, + "lightgbm": RegressionModelsLightGBM, + "randomforest": RegressionModelsRandomForest, + "sgd": RegressionModelsSGD, + "xgboostregressor": RegressionModelsXGBoostRegressor, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RegressionModels(input) + return &out, nil +} + +type RegressionPrimaryMetrics string + +const ( + RegressionPrimaryMetricsNormalizedMeanAbsoluteError RegressionPrimaryMetrics = "NormalizedMeanAbsoluteError" + RegressionPrimaryMetricsNormalizedRootMeanSquaredError RegressionPrimaryMetrics = "NormalizedRootMeanSquaredError" + RegressionPrimaryMetricsRTwoScore RegressionPrimaryMetrics = "R2Score" + RegressionPrimaryMetricsSpearmanCorrelation RegressionPrimaryMetrics = "SpearmanCorrelation" +) + +func PossibleValuesForRegressionPrimaryMetrics() []string { + return []string{ + string(RegressionPrimaryMetricsNormalizedMeanAbsoluteError), + string(RegressionPrimaryMetricsNormalizedRootMeanSquaredError), + string(RegressionPrimaryMetricsRTwoScore), + string(RegressionPrimaryMetricsSpearmanCorrelation), + } +} + +func (s *RegressionPrimaryMetrics) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRegressionPrimaryMetrics(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRegressionPrimaryMetrics(input string) (*RegressionPrimaryMetrics, error) { + vals := map[string]RegressionPrimaryMetrics{ + "normalizedmeanabsoluteerror": RegressionPrimaryMetricsNormalizedMeanAbsoluteError, + "normalizedrootmeansquarederror": RegressionPrimaryMetricsNormalizedRootMeanSquaredError, + "r2score": RegressionPrimaryMetricsRTwoScore, + "spearmancorrelation": RegressionPrimaryMetricsSpearmanCorrelation, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RegressionPrimaryMetrics(input) + return &out, nil +} + +type SamplingAlgorithmType string + +const ( + SamplingAlgorithmTypeBayesian SamplingAlgorithmType = "Bayesian" + SamplingAlgorithmTypeGrid SamplingAlgorithmType = "Grid" + SamplingAlgorithmTypeRandom SamplingAlgorithmType = "Random" +) + +func PossibleValuesForSamplingAlgorithmType() []string { + return []string{ + string(SamplingAlgorithmTypeBayesian), + string(SamplingAlgorithmTypeGrid), + string(SamplingAlgorithmTypeRandom), + } +} + +func (s *SamplingAlgorithmType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSamplingAlgorithmType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSamplingAlgorithmType(input string) (*SamplingAlgorithmType, error) { + vals := map[string]SamplingAlgorithmType{ + "bayesian": SamplingAlgorithmTypeBayesian, + "grid": SamplingAlgorithmTypeGrid, + "random": SamplingAlgorithmTypeRandom, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SamplingAlgorithmType(input) + return &out, nil +} + +type SeasonalityMode string + +const ( + SeasonalityModeAuto SeasonalityMode = "Auto" + SeasonalityModeCustom SeasonalityMode = "Custom" +) + +func PossibleValuesForSeasonalityMode() []string { + return []string{ + string(SeasonalityModeAuto), + string(SeasonalityModeCustom), + } +} + +func (s *SeasonalityMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSeasonalityMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSeasonalityMode(input string) (*SeasonalityMode, error) { + vals := map[string]SeasonalityMode{ + "auto": SeasonalityModeAuto, + "custom": SeasonalityModeCustom, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SeasonalityMode(input) + return &out, nil +} + +type ShortSeriesHandlingConfiguration string + +const ( + ShortSeriesHandlingConfigurationAuto ShortSeriesHandlingConfiguration = "Auto" + ShortSeriesHandlingConfigurationDrop ShortSeriesHandlingConfiguration = "Drop" + ShortSeriesHandlingConfigurationNone ShortSeriesHandlingConfiguration = "None" + ShortSeriesHandlingConfigurationPad ShortSeriesHandlingConfiguration = "Pad" +) + +func PossibleValuesForShortSeriesHandlingConfiguration() []string { + return []string{ + string(ShortSeriesHandlingConfigurationAuto), + string(ShortSeriesHandlingConfigurationDrop), + string(ShortSeriesHandlingConfigurationNone), + string(ShortSeriesHandlingConfigurationPad), + } +} + +func (s *ShortSeriesHandlingConfiguration) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseShortSeriesHandlingConfiguration(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseShortSeriesHandlingConfiguration(input string) (*ShortSeriesHandlingConfiguration, error) { + vals := map[string]ShortSeriesHandlingConfiguration{ + "auto": ShortSeriesHandlingConfigurationAuto, + "drop": ShortSeriesHandlingConfigurationDrop, + "none": ShortSeriesHandlingConfigurationNone, + "pad": ShortSeriesHandlingConfigurationPad, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ShortSeriesHandlingConfiguration(input) + return &out, nil +} + +type SparkJobEntryType string + +const ( + SparkJobEntryTypeSparkJobPythonEntry SparkJobEntryType = "SparkJobPythonEntry" + SparkJobEntryTypeSparkJobScalaEntry SparkJobEntryType = "SparkJobScalaEntry" +) + +func PossibleValuesForSparkJobEntryType() []string { + return []string{ + string(SparkJobEntryTypeSparkJobPythonEntry), + string(SparkJobEntryTypeSparkJobScalaEntry), + } +} + +func (s *SparkJobEntryType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSparkJobEntryType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSparkJobEntryType(input string) (*SparkJobEntryType, error) { + vals := map[string]SparkJobEntryType{ + "sparkjobpythonentry": SparkJobEntryTypeSparkJobPythonEntry, + "sparkjobscalaentry": SparkJobEntryTypeSparkJobScalaEntry, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SparkJobEntryType(input) + return &out, nil +} + +type StackMetaLearnerType string + +const ( + StackMetaLearnerTypeElasticNet StackMetaLearnerType = "ElasticNet" + StackMetaLearnerTypeElasticNetCV StackMetaLearnerType = "ElasticNetCV" + StackMetaLearnerTypeLightGBMClassifier StackMetaLearnerType = "LightGBMClassifier" + StackMetaLearnerTypeLightGBMRegressor StackMetaLearnerType = "LightGBMRegressor" + StackMetaLearnerTypeLinearRegression StackMetaLearnerType = "LinearRegression" + StackMetaLearnerTypeLogisticRegression StackMetaLearnerType = "LogisticRegression" + StackMetaLearnerTypeLogisticRegressionCV StackMetaLearnerType = "LogisticRegressionCV" + StackMetaLearnerTypeNone StackMetaLearnerType = "None" +) + +func PossibleValuesForStackMetaLearnerType() []string { + return []string{ + string(StackMetaLearnerTypeElasticNet), + string(StackMetaLearnerTypeElasticNetCV), + string(StackMetaLearnerTypeLightGBMClassifier), + string(StackMetaLearnerTypeLightGBMRegressor), + string(StackMetaLearnerTypeLinearRegression), + string(StackMetaLearnerTypeLogisticRegression), + string(StackMetaLearnerTypeLogisticRegressionCV), + string(StackMetaLearnerTypeNone), + } +} + +func (s *StackMetaLearnerType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStackMetaLearnerType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStackMetaLearnerType(input string) (*StackMetaLearnerType, error) { + vals := map[string]StackMetaLearnerType{ + "elasticnet": StackMetaLearnerTypeElasticNet, + "elasticnetcv": StackMetaLearnerTypeElasticNetCV, + "lightgbmclassifier": StackMetaLearnerTypeLightGBMClassifier, + "lightgbmregressor": StackMetaLearnerTypeLightGBMRegressor, + "linearregression": StackMetaLearnerTypeLinearRegression, + "logisticregression": StackMetaLearnerTypeLogisticRegression, + "logisticregressioncv": StackMetaLearnerTypeLogisticRegressionCV, + "none": StackMetaLearnerTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StackMetaLearnerType(input) + return &out, nil +} + +type StochasticOptimizer string + +const ( + StochasticOptimizerAdam StochasticOptimizer = "Adam" + StochasticOptimizerAdamw StochasticOptimizer = "Adamw" + StochasticOptimizerNone StochasticOptimizer = "None" + StochasticOptimizerSgd StochasticOptimizer = "Sgd" +) + +func PossibleValuesForStochasticOptimizer() []string { + return []string{ + string(StochasticOptimizerAdam), + string(StochasticOptimizerAdamw), + string(StochasticOptimizerNone), + string(StochasticOptimizerSgd), + } +} + +func (s *StochasticOptimizer) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStochasticOptimizer(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStochasticOptimizer(input string) (*StochasticOptimizer, error) { + vals := map[string]StochasticOptimizer{ + "adam": StochasticOptimizerAdam, + "adamw": StochasticOptimizerAdamw, + "none": StochasticOptimizerNone, + "sgd": StochasticOptimizerSgd, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StochasticOptimizer(input) + return &out, nil +} + +type TargetAggregationFunction string + +const ( + TargetAggregationFunctionMax TargetAggregationFunction = "Max" + TargetAggregationFunctionMean TargetAggregationFunction = "Mean" + TargetAggregationFunctionMin TargetAggregationFunction = "Min" + TargetAggregationFunctionNone TargetAggregationFunction = "None" + TargetAggregationFunctionSum TargetAggregationFunction = "Sum" +) + +func PossibleValuesForTargetAggregationFunction() []string { + return []string{ + string(TargetAggregationFunctionMax), + string(TargetAggregationFunctionMean), + string(TargetAggregationFunctionMin), + string(TargetAggregationFunctionNone), + string(TargetAggregationFunctionSum), + } +} + +func (s *TargetAggregationFunction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTargetAggregationFunction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTargetAggregationFunction(input string) (*TargetAggregationFunction, error) { + vals := map[string]TargetAggregationFunction{ + "max": TargetAggregationFunctionMax, + "mean": TargetAggregationFunctionMean, + "min": TargetAggregationFunctionMin, + "none": TargetAggregationFunctionNone, + "sum": TargetAggregationFunctionSum, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TargetAggregationFunction(input) + return &out, nil +} + +type TargetLagsMode string + +const ( + TargetLagsModeAuto TargetLagsMode = "Auto" + TargetLagsModeCustom TargetLagsMode = "Custom" +) + +func PossibleValuesForTargetLagsMode() []string { + return []string{ + string(TargetLagsModeAuto), + string(TargetLagsModeCustom), + } +} + +func (s *TargetLagsMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTargetLagsMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTargetLagsMode(input string) (*TargetLagsMode, error) { + vals := map[string]TargetLagsMode{ + "auto": TargetLagsModeAuto, + "custom": TargetLagsModeCustom, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TargetLagsMode(input) + return &out, nil +} + +type TargetRollingWindowSizeMode string + +const ( + TargetRollingWindowSizeModeAuto TargetRollingWindowSizeMode = "Auto" + TargetRollingWindowSizeModeCustom TargetRollingWindowSizeMode = "Custom" +) + +func PossibleValuesForTargetRollingWindowSizeMode() []string { + return []string{ + string(TargetRollingWindowSizeModeAuto), + string(TargetRollingWindowSizeModeCustom), + } +} + +func (s *TargetRollingWindowSizeMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTargetRollingWindowSizeMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTargetRollingWindowSizeMode(input string) (*TargetRollingWindowSizeMode, error) { + vals := map[string]TargetRollingWindowSizeMode{ + "auto": TargetRollingWindowSizeModeAuto, + "custom": TargetRollingWindowSizeModeCustom, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TargetRollingWindowSizeMode(input) + return &out, nil +} + +type TaskType string + +const ( + TaskTypeClassification TaskType = "Classification" + TaskTypeForecasting TaskType = "Forecasting" + TaskTypeImageClassification TaskType = "ImageClassification" + TaskTypeImageClassificationMultilabel TaskType = "ImageClassificationMultilabel" + TaskTypeImageInstanceSegmentation TaskType = "ImageInstanceSegmentation" + TaskTypeImageObjectDetection TaskType = "ImageObjectDetection" + TaskTypeRegression TaskType = "Regression" + TaskTypeTextClassification TaskType = "TextClassification" + TaskTypeTextClassificationMultilabel TaskType = "TextClassificationMultilabel" + TaskTypeTextNER TaskType = "TextNER" +) + +func PossibleValuesForTaskType() []string { + return []string{ + string(TaskTypeClassification), + string(TaskTypeForecasting), + string(TaskTypeImageClassification), + string(TaskTypeImageClassificationMultilabel), + string(TaskTypeImageInstanceSegmentation), + string(TaskTypeImageObjectDetection), + string(TaskTypeRegression), + string(TaskTypeTextClassification), + string(TaskTypeTextClassificationMultilabel), + string(TaskTypeTextNER), + } +} + +func (s *TaskType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTaskType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTaskType(input string) (*TaskType, error) { + vals := map[string]TaskType{ + "classification": TaskTypeClassification, + "forecasting": TaskTypeForecasting, + "imageclassification": TaskTypeImageClassification, + "imageclassificationmultilabel": TaskTypeImageClassificationMultilabel, + "imageinstancesegmentation": TaskTypeImageInstanceSegmentation, + "imageobjectdetection": TaskTypeImageObjectDetection, + "regression": TaskTypeRegression, + "textclassification": TaskTypeTextClassification, + "textclassificationmultilabel": TaskTypeTextClassificationMultilabel, + "textner": TaskTypeTextNER, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TaskType(input) + return &out, nil +} + +type UseStl string + +const ( + UseStlNone UseStl = "None" + UseStlSeason UseStl = "Season" + UseStlSeasonTrend UseStl = "SeasonTrend" +) + +func PossibleValuesForUseStl() []string { + return []string{ + string(UseStlNone), + string(UseStlSeason), + string(UseStlSeasonTrend), + } +} + +func (s *UseStl) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUseStl(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUseStl(input string) (*UseStl, error) { + vals := map[string]UseStl{ + "none": UseStlNone, + "season": UseStlSeason, + "seasontrend": UseStlSeasonTrend, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UseStl(input) + return &out, nil +} + +type ValidationMetricType string + +const ( + ValidationMetricTypeCoco ValidationMetricType = "Coco" + ValidationMetricTypeCocoVoc ValidationMetricType = "CocoVoc" + ValidationMetricTypeNone ValidationMetricType = "None" + ValidationMetricTypeVoc ValidationMetricType = "Voc" +) + +func PossibleValuesForValidationMetricType() []string { + return []string{ + string(ValidationMetricTypeCoco), + string(ValidationMetricTypeCocoVoc), + string(ValidationMetricTypeNone), + string(ValidationMetricTypeVoc), + } +} + +func (s *ValidationMetricType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseValidationMetricType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseValidationMetricType(input string) (*ValidationMetricType, error) { + vals := map[string]ValidationMetricType{ + "coco": ValidationMetricTypeCoco, + "cocovoc": ValidationMetricTypeCocoVoc, + "none": ValidationMetricTypeNone, + "voc": ValidationMetricTypeVoc, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ValidationMetricType(input) + return &out, nil +} + +type WebhookType string + +const ( + WebhookTypeAzureDevOps WebhookType = "AzureDevOps" +) + +func PossibleValuesForWebhookType() []string { + return []string{ + string(WebhookTypeAzureDevOps), + } +} + +func (s *WebhookType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWebhookType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWebhookType(input string) (*WebhookType, error) { + vals := map[string]WebhookType{ + "azuredevops": WebhookTypeAzureDevOps, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WebhookType(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/id_job.go b/resource-manager/machinelearningservices/2025-04-01/job/id_job.go new file mode 100644 index 00000000000..50d7fa227e1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/id_job.go @@ -0,0 +1,139 @@ +package job + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&JobId{}) +} + +var _ resourceids.ResourceId = &JobId{} + +// JobId is a struct representing the Resource ID for a Job +type JobId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + JobName string +} + +// NewJobID returns a new JobId struct +func NewJobID(subscriptionId string, resourceGroupName string, workspaceName string, jobName string) JobId { + return JobId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + JobName: jobName, + } +} + +// ParseJobID parses 'input' into a JobId +func ParseJobID(input string) (*JobId, error) { + parser := resourceids.NewParserFromResourceIdType(&JobId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := JobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseJobIDInsensitively parses 'input' case-insensitively into a JobId +// note: this method should only be used for API response data and not user input +func ParseJobIDInsensitively(input string) (*JobId, error) { + parser := resourceids.NewParserFromResourceIdType(&JobId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := JobId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *JobId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.JobName, ok = input.Parsed["jobName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "jobName", input) + } + + return nil +} + +// ValidateJobID checks that 'input' can be parsed as a Job ID +func ValidateJobID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseJobID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Job ID +func (id JobId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/jobs/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.JobName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Job ID +func (id JobId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticJobs", "jobs", "jobs"), + resourceids.UserSpecifiedSegment("jobName", "jobName"), + } +} + +// String returns a human-readable description of this Job ID +func (id JobId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Job Name: %q", id.JobName), + } + return fmt.Sprintf("Job (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/id_job_test.go b/resource-manager/machinelearningservices/2025-04-01/job/id_job_test.go new file mode 100644 index 00000000000..452ce4f41f5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/id_job_test.go @@ -0,0 +1,327 @@ +package job + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &JobId{} + +func TestNewJobID(t *testing.T) { + id := NewJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "jobName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.JobName != "jobName" { + t.Fatalf("Expected %q but got %q for Segment 'JobName'", id.JobName, "jobName") + } +} + +func TestFormatJobID(t *testing.T) { + actual := NewJobID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "jobName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/jobs/jobName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseJobID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *JobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/jobs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/jobs/jobName", + Expected: &JobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + JobName: "jobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/jobs/jobName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseJobID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.JobName != v.Expected.JobName { + t.Fatalf("Expected %q but got %q for JobName", v.Expected.JobName, actual.JobName) + } + + } +} + +func TestParseJobIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *JobId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/jobs", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/jObS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/jobs/jobName", + Expected: &JobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + JobName: "jobName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/jobs/jobName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/jObS/jObNaMe", + Expected: &JobId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + JobName: "jObNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/jObS/jObNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseJobIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.JobName != v.Expected.JobName { + t.Fatalf("Expected %q but got %q for JobName", v.Expected.JobName, actual.JobName) + } + + } +} + +func TestSegmentsForJobId(t *testing.T) { + segments := JobId{}.Segments() + if len(segments) == 0 { + t.Fatalf("JobId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/id_workspace.go b/resource-manager/machinelearningservices/2025-04-01/job/id_workspace.go new file mode 100644 index 00000000000..39245bff768 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/id_workspace.go @@ -0,0 +1,130 @@ +package job + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/id_workspace_test.go b/resource-manager/machinelearningservices/2025-04-01/job/id_workspace_test.go new file mode 100644 index 00000000000..04b8fba7cfc --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/id_workspace_test.go @@ -0,0 +1,282 @@ +package job + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/method_cancel.go b/resource-manager/machinelearningservices/2025-04-01/job/method_cancel.go new file mode 100644 index 00000000000..e1b0f828526 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/method_cancel.go @@ -0,0 +1,70 @@ +package job + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 +} + +// Cancel ... +func (c JobClient) Cancel(ctx context.Context, id JobId) (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 JobClient) CancelThenPoll(ctx context.Context, id JobId) 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/machinelearningservices/2025-04-01/job/method_createorupdate.go b/resource-manager/machinelearningservices/2025-04-01/job/method_createorupdate.go new file mode 100644 index 00000000000..109e9ae6e10 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/method_createorupdate.go @@ -0,0 +1,58 @@ +package job + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *JobBaseResource +} + +// CreateOrUpdate ... +func (c JobClient) CreateOrUpdate(ctx context.Context, id JobId, input JobBaseResource) (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 JobBaseResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/method_delete.go b/resource-manager/machinelearningservices/2025-04-01/job/method_delete.go new file mode 100644 index 00000000000..0217b1a6143 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/method_delete.go @@ -0,0 +1,71 @@ +package job + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 JobClient) Delete(ctx context.Context, id JobId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c JobClient) DeleteThenPoll(ctx context.Context, id JobId) 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/machinelearningservices/2025-04-01/job/method_get.go b/resource-manager/machinelearningservices/2025-04-01/job/method_get.go new file mode 100644 index 00000000000..3a3d38b8bea --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/method_get.go @@ -0,0 +1,53 @@ +package job + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *JobBaseResource +} + +// Get ... +func (c JobClient) Get(ctx context.Context, id JobId) (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 JobBaseResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/method_list.go b/resource-manager/machinelearningservices/2025-04-01/job/method_list.go new file mode 100644 index 00000000000..e293d4ba17d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/method_list.go @@ -0,0 +1,150 @@ +package job + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]JobBaseResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []JobBaseResource +} + +type ListOperationOptions struct { + JobType *string + ListViewType *ListViewType + Properties *string + Skip *string + Tag *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.JobType != nil { + out.Append("jobType", fmt.Sprintf("%v", *o.JobType)) + } + if o.ListViewType != nil { + out.Append("listViewType", fmt.Sprintf("%v", *o.ListViewType)) + } + if o.Properties != nil { + out.Append("properties", fmt.Sprintf("%v", *o.Properties)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Tag != nil { + out.Append("tag", fmt.Sprintf("%v", *o.Tag)) + } + 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 JobClient) List(ctx context.Context, id WorkspaceId, 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/jobs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]JobBaseResource `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 JobClient) ListComplete(ctx context.Context, id WorkspaceId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, JobBaseResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c JobClient) ListCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, options ListOperationOptions, predicate JobBaseResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]JobBaseResource, 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/machinelearningservices/2025-04-01/job/model_allnodes.go b/resource-manager/machinelearningservices/2025-04-01/job/model_allnodes.go new file mode 100644 index 00000000000..d40cabeeda6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_allnodes.go @@ -0,0 +1,49 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Nodes = AllNodes{} + +type AllNodes struct { + + // Fields inherited from Nodes + + NodesValueType NodesValueType `json:"nodesValueType"` +} + +func (s AllNodes) Nodes() BaseNodesImpl { + return BaseNodesImpl{ + NodesValueType: s.NodesValueType, + } +} + +var _ json.Marshaler = AllNodes{} + +func (s AllNodes) MarshalJSON() ([]byte, error) { + type wrapper AllNodes + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AllNodes: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AllNodes: %+v", err) + } + + decoded["nodesValueType"] = "All" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AllNodes: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_amltoken.go b/resource-manager/machinelearningservices/2025-04-01/job/model_amltoken.go new file mode 100644 index 00000000000..cd60c336de5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_amltoken.go @@ -0,0 +1,49 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ IdentityConfiguration = AmlToken{} + +type AmlToken struct { + + // Fields inherited from IdentityConfiguration + + IdentityType IdentityConfigurationType `json:"identityType"` +} + +func (s AmlToken) IdentityConfiguration() BaseIdentityConfigurationImpl { + return BaseIdentityConfigurationImpl{ + IdentityType: s.IdentityType, + } +} + +var _ json.Marshaler = AmlToken{} + +func (s AmlToken) MarshalJSON() ([]byte, error) { + type wrapper AmlToken + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AmlToken: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AmlToken: %+v", err) + } + + decoded["identityType"] = "AMLToken" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AmlToken: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_autoforecasthorizon.go b/resource-manager/machinelearningservices/2025-04-01/job/model_autoforecasthorizon.go new file mode 100644 index 00000000000..a230f6b5837 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_autoforecasthorizon.go @@ -0,0 +1,49 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ForecastHorizon = AutoForecastHorizon{} + +type AutoForecastHorizon struct { + + // Fields inherited from ForecastHorizon + + Mode ForecastHorizonMode `json:"mode"` +} + +func (s AutoForecastHorizon) ForecastHorizon() BaseForecastHorizonImpl { + return BaseForecastHorizonImpl{ + Mode: s.Mode, + } +} + +var _ json.Marshaler = AutoForecastHorizon{} + +func (s AutoForecastHorizon) MarshalJSON() ([]byte, error) { + type wrapper AutoForecastHorizon + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AutoForecastHorizon: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AutoForecastHorizon: %+v", err) + } + + decoded["mode"] = "Auto" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AutoForecastHorizon: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_automljob.go b/resource-manager/machinelearningservices/2025-04-01/job/model_automljob.go new file mode 100644 index 00000000000..e07e0db0435 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_automljob.go @@ -0,0 +1,162 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobBase = AutoMLJob{} + +type AutoMLJob struct { + EnvironmentId *string `json:"environmentId,omitempty"` + EnvironmentVariables *map[string]string `json:"environmentVariables,omitempty"` + Outputs *map[string]JobOutput `json:"outputs,omitempty"` + QueueSettings *QueueSettings `json:"queueSettings,omitempty"` + Resources *JobResourceConfiguration `json:"resources,omitempty"` + TaskDetails AutoMLVertical `json:"taskDetails"` + + // Fields inherited from JobBase + + ComponentId *string `json:"componentId,omitempty"` + ComputeId *string `json:"computeId,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExperimentName *string `json:"experimentName,omitempty"` + Identity IdentityConfiguration `json:"identity"` + IsArchived *bool `json:"isArchived,omitempty"` + JobType JobType `json:"jobType"` + NotificationSetting *NotificationSetting `json:"notificationSetting,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Services *map[string]JobService `json:"services,omitempty"` + Status *JobStatus `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +func (s AutoMLJob) JobBase() BaseJobBaseImpl { + return BaseJobBaseImpl{ + ComponentId: s.ComponentId, + ComputeId: s.ComputeId, + Description: s.Description, + DisplayName: s.DisplayName, + ExperimentName: s.ExperimentName, + Identity: s.Identity, + IsArchived: s.IsArchived, + JobType: s.JobType, + NotificationSetting: s.NotificationSetting, + Properties: s.Properties, + Services: s.Services, + Status: s.Status, + Tags: s.Tags, + } +} + +var _ json.Marshaler = AutoMLJob{} + +func (s AutoMLJob) MarshalJSON() ([]byte, error) { + type wrapper AutoMLJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AutoMLJob: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AutoMLJob: %+v", err) + } + + decoded["jobType"] = "AutoML" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AutoMLJob: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &AutoMLJob{} + +func (s *AutoMLJob) UnmarshalJSON(bytes []byte) error { + var decoded struct { + EnvironmentId *string `json:"environmentId,omitempty"` + EnvironmentVariables *map[string]string `json:"environmentVariables,omitempty"` + QueueSettings *QueueSettings `json:"queueSettings,omitempty"` + Resources *JobResourceConfiguration `json:"resources,omitempty"` + ComponentId *string `json:"componentId,omitempty"` + ComputeId *string `json:"computeId,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExperimentName *string `json:"experimentName,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + JobType JobType `json:"jobType"` + NotificationSetting *NotificationSetting `json:"notificationSetting,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Services *map[string]JobService `json:"services,omitempty"` + Status *JobStatus `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.EnvironmentId = decoded.EnvironmentId + s.EnvironmentVariables = decoded.EnvironmentVariables + s.QueueSettings = decoded.QueueSettings + s.Resources = decoded.Resources + s.ComponentId = decoded.ComponentId + s.ComputeId = decoded.ComputeId + s.Description = decoded.Description + s.DisplayName = decoded.DisplayName + s.ExperimentName = decoded.ExperimentName + s.IsArchived = decoded.IsArchived + s.JobType = decoded.JobType + s.NotificationSetting = decoded.NotificationSetting + s.Properties = decoded.Properties + s.Services = decoded.Services + s.Status = decoded.Status + s.Tags = decoded.Tags + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AutoMLJob into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["identity"]; ok { + impl, err := UnmarshalIdentityConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Identity' for 'AutoMLJob': %+v", err) + } + s.Identity = impl + } + + if v, ok := temp["outputs"]; ok { + var dictionaryTemp map[string]json.RawMessage + if err := json.Unmarshal(v, &dictionaryTemp); err != nil { + return fmt.Errorf("unmarshaling Outputs into dictionary map[string]json.RawMessage: %+v", err) + } + + output := make(map[string]JobOutput) + for key, val := range dictionaryTemp { + impl, err := UnmarshalJobOutputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling key %q field 'Outputs' for 'AutoMLJob': %+v", key, err) + } + output[key] = impl + } + s.Outputs = &output + } + + if v, ok := temp["taskDetails"]; ok { + impl, err := UnmarshalAutoMLVerticalImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'TaskDetails' for 'AutoMLJob': %+v", err) + } + s.TaskDetails = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_automlvertical.go b/resource-manager/machinelearningservices/2025-04-01/job/model_automlvertical.go new file mode 100644 index 00000000000..9315c3a9295 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_automlvertical.go @@ -0,0 +1,150 @@ +package job + +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 AutoMLVertical interface { + AutoMLVertical() BaseAutoMLVerticalImpl +} + +var _ AutoMLVertical = BaseAutoMLVerticalImpl{} + +type BaseAutoMLVerticalImpl struct { + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` +} + +func (s BaseAutoMLVerticalImpl) AutoMLVertical() BaseAutoMLVerticalImpl { + return s +} + +var _ AutoMLVertical = RawAutoMLVerticalImpl{} + +// RawAutoMLVerticalImpl 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 RawAutoMLVerticalImpl struct { + autoMLVertical BaseAutoMLVerticalImpl + Type string + Values map[string]interface{} +} + +func (s RawAutoMLVerticalImpl) AutoMLVertical() BaseAutoMLVerticalImpl { + return s.autoMLVertical +} + +func UnmarshalAutoMLVerticalImplementation(input []byte) (AutoMLVertical, 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 AutoMLVertical into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["taskType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Classification") { + var out Classification + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into Classification: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Forecasting") { + var out Forecasting + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into Forecasting: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ImageClassification") { + var out ImageClassification + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ImageClassification: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ImageClassificationMultilabel") { + var out ImageClassificationMultilabel + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ImageClassificationMultilabel: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ImageInstanceSegmentation") { + var out ImageInstanceSegmentation + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ImageInstanceSegmentation: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ImageObjectDetection") { + var out ImageObjectDetection + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ImageObjectDetection: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Regression") { + var out Regression + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into Regression: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "TextClassification") { + var out TextClassification + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into TextClassification: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "TextClassificationMultilabel") { + var out TextClassificationMultilabel + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into TextClassificationMultilabel: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "TextNER") { + var out TextNer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into TextNer: %+v", err) + } + return out, nil + } + + var parent BaseAutoMLVerticalImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseAutoMLVerticalImpl: %+v", err) + } + + return RawAutoMLVerticalImpl{ + autoMLVertical: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_autoncrossvalidations.go b/resource-manager/machinelearningservices/2025-04-01/job/model_autoncrossvalidations.go new file mode 100644 index 00000000000..bee0973267a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_autoncrossvalidations.go @@ -0,0 +1,49 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ NCrossValidations = AutoNCrossValidations{} + +type AutoNCrossValidations struct { + + // Fields inherited from NCrossValidations + + Mode NCrossValidationsMode `json:"mode"` +} + +func (s AutoNCrossValidations) NCrossValidations() BaseNCrossValidationsImpl { + return BaseNCrossValidationsImpl{ + Mode: s.Mode, + } +} + +var _ json.Marshaler = AutoNCrossValidations{} + +func (s AutoNCrossValidations) MarshalJSON() ([]byte, error) { + type wrapper AutoNCrossValidations + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AutoNCrossValidations: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AutoNCrossValidations: %+v", err) + } + + decoded["mode"] = "Auto" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AutoNCrossValidations: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_autoseasonality.go b/resource-manager/machinelearningservices/2025-04-01/job/model_autoseasonality.go new file mode 100644 index 00000000000..191c715de57 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_autoseasonality.go @@ -0,0 +1,49 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Seasonality = AutoSeasonality{} + +type AutoSeasonality struct { + + // Fields inherited from Seasonality + + Mode SeasonalityMode `json:"mode"` +} + +func (s AutoSeasonality) Seasonality() BaseSeasonalityImpl { + return BaseSeasonalityImpl{ + Mode: s.Mode, + } +} + +var _ json.Marshaler = AutoSeasonality{} + +func (s AutoSeasonality) MarshalJSON() ([]byte, error) { + type wrapper AutoSeasonality + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AutoSeasonality: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AutoSeasonality: %+v", err) + } + + decoded["mode"] = "Auto" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AutoSeasonality: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_autotargetlags.go b/resource-manager/machinelearningservices/2025-04-01/job/model_autotargetlags.go new file mode 100644 index 00000000000..0e617e2455d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_autotargetlags.go @@ -0,0 +1,49 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TargetLags = AutoTargetLags{} + +type AutoTargetLags struct { + + // Fields inherited from TargetLags + + Mode TargetLagsMode `json:"mode"` +} + +func (s AutoTargetLags) TargetLags() BaseTargetLagsImpl { + return BaseTargetLagsImpl{ + Mode: s.Mode, + } +} + +var _ json.Marshaler = AutoTargetLags{} + +func (s AutoTargetLags) MarshalJSON() ([]byte, error) { + type wrapper AutoTargetLags + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AutoTargetLags: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AutoTargetLags: %+v", err) + } + + decoded["mode"] = "Auto" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AutoTargetLags: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_autotargetrollingwindowsize.go b/resource-manager/machinelearningservices/2025-04-01/job/model_autotargetrollingwindowsize.go new file mode 100644 index 00000000000..724a92305cf --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_autotargetrollingwindowsize.go @@ -0,0 +1,49 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TargetRollingWindowSize = AutoTargetRollingWindowSize{} + +type AutoTargetRollingWindowSize struct { + + // Fields inherited from TargetRollingWindowSize + + Mode TargetRollingWindowSizeMode `json:"mode"` +} + +func (s AutoTargetRollingWindowSize) TargetRollingWindowSize() BaseTargetRollingWindowSizeImpl { + return BaseTargetRollingWindowSizeImpl{ + Mode: s.Mode, + } +} + +var _ json.Marshaler = AutoTargetRollingWindowSize{} + +func (s AutoTargetRollingWindowSize) MarshalJSON() ([]byte, error) { + type wrapper AutoTargetRollingWindowSize + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AutoTargetRollingWindowSize: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AutoTargetRollingWindowSize: %+v", err) + } + + decoded["mode"] = "Auto" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AutoTargetRollingWindowSize: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_azuredevopswebhook.go b/resource-manager/machinelearningservices/2025-04-01/job/model_azuredevopswebhook.go new file mode 100644 index 00000000000..9e66f4a68ee --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_azuredevopswebhook.go @@ -0,0 +1,51 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Webhook = AzureDevOpsWebhook{} + +type AzureDevOpsWebhook struct { + + // Fields inherited from Webhook + + EventType *string `json:"eventType,omitempty"` + WebhookType WebhookType `json:"webhookType"` +} + +func (s AzureDevOpsWebhook) Webhook() BaseWebhookImpl { + return BaseWebhookImpl{ + EventType: s.EventType, + WebhookType: s.WebhookType, + } +} + +var _ json.Marshaler = AzureDevOpsWebhook{} + +func (s AzureDevOpsWebhook) MarshalJSON() ([]byte, error) { + type wrapper AzureDevOpsWebhook + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureDevOpsWebhook: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureDevOpsWebhook: %+v", err) + } + + decoded["webhookType"] = "AzureDevOps" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureDevOpsWebhook: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_banditpolicy.go b/resource-manager/machinelearningservices/2025-04-01/job/model_banditpolicy.go new file mode 100644 index 00000000000..da5ec6d8110 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_banditpolicy.go @@ -0,0 +1,55 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EarlyTerminationPolicy = BanditPolicy{} + +type BanditPolicy struct { + SlackAmount *float64 `json:"slackAmount,omitempty"` + SlackFactor *float64 `json:"slackFactor,omitempty"` + + // Fields inherited from EarlyTerminationPolicy + + DelayEvaluation *int64 `json:"delayEvaluation,omitempty"` + EvaluationInterval *int64 `json:"evaluationInterval,omitempty"` + PolicyType EarlyTerminationPolicyType `json:"policyType"` +} + +func (s BanditPolicy) EarlyTerminationPolicy() BaseEarlyTerminationPolicyImpl { + return BaseEarlyTerminationPolicyImpl{ + DelayEvaluation: s.DelayEvaluation, + EvaluationInterval: s.EvaluationInterval, + PolicyType: s.PolicyType, + } +} + +var _ json.Marshaler = BanditPolicy{} + +func (s BanditPolicy) MarshalJSON() ([]byte, error) { + type wrapper BanditPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling BanditPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling BanditPolicy: %+v", err) + } + + decoded["policyType"] = "Bandit" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling BanditPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_bayesiansamplingalgorithm.go b/resource-manager/machinelearningservices/2025-04-01/job/model_bayesiansamplingalgorithm.go new file mode 100644 index 00000000000..c5d265166ac --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_bayesiansamplingalgorithm.go @@ -0,0 +1,49 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SamplingAlgorithm = BayesianSamplingAlgorithm{} + +type BayesianSamplingAlgorithm struct { + + // Fields inherited from SamplingAlgorithm + + SamplingAlgorithmType SamplingAlgorithmType `json:"samplingAlgorithmType"` +} + +func (s BayesianSamplingAlgorithm) SamplingAlgorithm() BaseSamplingAlgorithmImpl { + return BaseSamplingAlgorithmImpl{ + SamplingAlgorithmType: s.SamplingAlgorithmType, + } +} + +var _ json.Marshaler = BayesianSamplingAlgorithm{} + +func (s BayesianSamplingAlgorithm) MarshalJSON() ([]byte, error) { + type wrapper BayesianSamplingAlgorithm + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling BayesianSamplingAlgorithm: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling BayesianSamplingAlgorithm: %+v", err) + } + + decoded["samplingAlgorithmType"] = "Bayesian" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling BayesianSamplingAlgorithm: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_classification.go b/resource-manager/machinelearningservices/2025-04-01/job/model_classification.go new file mode 100644 index 00000000000..e67c3aeb994 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_classification.go @@ -0,0 +1,123 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AutoMLVertical = Classification{} + +type Classification struct { + CvSplitColumnNames *[]string `json:"cvSplitColumnNames,omitempty"` + FeaturizationSettings *TableVerticalFeaturizationSettings `json:"featurizationSettings,omitempty"` + LimitSettings *TableVerticalLimitSettings `json:"limitSettings,omitempty"` + NCrossValidations NCrossValidations `json:"nCrossValidations"` + PositiveLabel *string `json:"positiveLabel,omitempty"` + PrimaryMetric *ClassificationPrimaryMetrics `json:"primaryMetric,omitempty"` + TestData *MLTableJobInput `json:"testData,omitempty"` + TestDataSize *float64 `json:"testDataSize,omitempty"` + TrainingSettings *ClassificationTrainingSettings `json:"trainingSettings,omitempty"` + ValidationData *MLTableJobInput `json:"validationData,omitempty"` + ValidationDataSize *float64 `json:"validationDataSize,omitempty"` + WeightColumnName *string `json:"weightColumnName,omitempty"` + + // Fields inherited from AutoMLVertical + + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` +} + +func (s Classification) AutoMLVertical() BaseAutoMLVerticalImpl { + return BaseAutoMLVerticalImpl{ + LogVerbosity: s.LogVerbosity, + TargetColumnName: s.TargetColumnName, + TaskType: s.TaskType, + TrainingData: s.TrainingData, + } +} + +var _ json.Marshaler = Classification{} + +func (s Classification) MarshalJSON() ([]byte, error) { + type wrapper Classification + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling Classification: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling Classification: %+v", err) + } + + decoded["taskType"] = "Classification" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling Classification: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &Classification{} + +func (s *Classification) UnmarshalJSON(bytes []byte) error { + var decoded struct { + CvSplitColumnNames *[]string `json:"cvSplitColumnNames,omitempty"` + FeaturizationSettings *TableVerticalFeaturizationSettings `json:"featurizationSettings,omitempty"` + LimitSettings *TableVerticalLimitSettings `json:"limitSettings,omitempty"` + PositiveLabel *string `json:"positiveLabel,omitempty"` + PrimaryMetric *ClassificationPrimaryMetrics `json:"primaryMetric,omitempty"` + TestData *MLTableJobInput `json:"testData,omitempty"` + TestDataSize *float64 `json:"testDataSize,omitempty"` + TrainingSettings *ClassificationTrainingSettings `json:"trainingSettings,omitempty"` + ValidationData *MLTableJobInput `json:"validationData,omitempty"` + ValidationDataSize *float64 `json:"validationDataSize,omitempty"` + WeightColumnName *string `json:"weightColumnName,omitempty"` + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.CvSplitColumnNames = decoded.CvSplitColumnNames + s.FeaturizationSettings = decoded.FeaturizationSettings + s.LimitSettings = decoded.LimitSettings + s.PositiveLabel = decoded.PositiveLabel + s.PrimaryMetric = decoded.PrimaryMetric + s.TestData = decoded.TestData + s.TestDataSize = decoded.TestDataSize + s.TrainingSettings = decoded.TrainingSettings + s.ValidationData = decoded.ValidationData + s.ValidationDataSize = decoded.ValidationDataSize + s.WeightColumnName = decoded.WeightColumnName + s.LogVerbosity = decoded.LogVerbosity + s.TargetColumnName = decoded.TargetColumnName + s.TaskType = decoded.TaskType + s.TrainingData = decoded.TrainingData + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling Classification into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["nCrossValidations"]; ok { + impl, err := UnmarshalNCrossValidationsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'NCrossValidations' for 'Classification': %+v", err) + } + s.NCrossValidations = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_classificationtrainingsettings.go b/resource-manager/machinelearningservices/2025-04-01/job/model_classificationtrainingsettings.go new file mode 100644 index 00000000000..ec292905bbf --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_classificationtrainingsettings.go @@ -0,0 +1,16 @@ +package job + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClassificationTrainingSettings struct { + AllowedTrainingAlgorithms *[]ClassificationModels `json:"allowedTrainingAlgorithms,omitempty"` + BlockedTrainingAlgorithms *[]ClassificationModels `json:"blockedTrainingAlgorithms,omitempty"` + EnableDnnTraining *bool `json:"enableDnnTraining,omitempty"` + EnableModelExplainability *bool `json:"enableModelExplainability,omitempty"` + EnableOnnxCompatibleModels *bool `json:"enableOnnxCompatibleModels,omitempty"` + EnableStackEnsemble *bool `json:"enableStackEnsemble,omitempty"` + EnableVoteEnsemble *bool `json:"enableVoteEnsemble,omitempty"` + EnsembleModelDownloadTimeout *string `json:"ensembleModelDownloadTimeout,omitempty"` + StackEnsembleSettings *StackEnsembleSettings `json:"stackEnsembleSettings,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_columntransformer.go b/resource-manager/machinelearningservices/2025-04-01/job/model_columntransformer.go new file mode 100644 index 00000000000..21b30c99ee2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_columntransformer.go @@ -0,0 +1,9 @@ +package job + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ColumnTransformer struct { + Fields *[]string `json:"fields,omitempty"` + Parameters *interface{} `json:"parameters,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_commandjob.go b/resource-manager/machinelearningservices/2025-04-01/job/model_commandjob.go new file mode 100644 index 00000000000..8b02f60a87f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_commandjob.go @@ -0,0 +1,198 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobBase = CommandJob{} + +type CommandJob struct { + CodeId *string `json:"codeId,omitempty"` + Command string `json:"command"` + Distribution DistributionConfiguration `json:"distribution"` + EnvironmentId string `json:"environmentId"` + EnvironmentVariables *map[string]string `json:"environmentVariables,omitempty"` + Inputs *map[string]JobInput `json:"inputs,omitempty"` + Limits JobLimits `json:"limits"` + Outputs *map[string]JobOutput `json:"outputs,omitempty"` + Parameters *interface{} `json:"parameters,omitempty"` + QueueSettings *QueueSettings `json:"queueSettings,omitempty"` + Resources *JobResourceConfiguration `json:"resources,omitempty"` + + // Fields inherited from JobBase + + ComponentId *string `json:"componentId,omitempty"` + ComputeId *string `json:"computeId,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExperimentName *string `json:"experimentName,omitempty"` + Identity IdentityConfiguration `json:"identity"` + IsArchived *bool `json:"isArchived,omitempty"` + JobType JobType `json:"jobType"` + NotificationSetting *NotificationSetting `json:"notificationSetting,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Services *map[string]JobService `json:"services,omitempty"` + Status *JobStatus `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +func (s CommandJob) JobBase() BaseJobBaseImpl { + return BaseJobBaseImpl{ + ComponentId: s.ComponentId, + ComputeId: s.ComputeId, + Description: s.Description, + DisplayName: s.DisplayName, + ExperimentName: s.ExperimentName, + Identity: s.Identity, + IsArchived: s.IsArchived, + JobType: s.JobType, + NotificationSetting: s.NotificationSetting, + Properties: s.Properties, + Services: s.Services, + Status: s.Status, + Tags: s.Tags, + } +} + +var _ json.Marshaler = CommandJob{} + +func (s CommandJob) MarshalJSON() ([]byte, error) { + type wrapper CommandJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CommandJob: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CommandJob: %+v", err) + } + + decoded["jobType"] = "Command" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CommandJob: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &CommandJob{} + +func (s *CommandJob) UnmarshalJSON(bytes []byte) error { + var decoded struct { + CodeId *string `json:"codeId,omitempty"` + Command string `json:"command"` + EnvironmentId string `json:"environmentId"` + EnvironmentVariables *map[string]string `json:"environmentVariables,omitempty"` + Parameters *interface{} `json:"parameters,omitempty"` + QueueSettings *QueueSettings `json:"queueSettings,omitempty"` + Resources *JobResourceConfiguration `json:"resources,omitempty"` + ComponentId *string `json:"componentId,omitempty"` + ComputeId *string `json:"computeId,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExperimentName *string `json:"experimentName,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + JobType JobType `json:"jobType"` + NotificationSetting *NotificationSetting `json:"notificationSetting,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Services *map[string]JobService `json:"services,omitempty"` + Status *JobStatus `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.CodeId = decoded.CodeId + s.Command = decoded.Command + s.EnvironmentId = decoded.EnvironmentId + s.EnvironmentVariables = decoded.EnvironmentVariables + s.Parameters = decoded.Parameters + s.QueueSettings = decoded.QueueSettings + s.Resources = decoded.Resources + s.ComponentId = decoded.ComponentId + s.ComputeId = decoded.ComputeId + s.Description = decoded.Description + s.DisplayName = decoded.DisplayName + s.ExperimentName = decoded.ExperimentName + s.IsArchived = decoded.IsArchived + s.JobType = decoded.JobType + s.NotificationSetting = decoded.NotificationSetting + s.Properties = decoded.Properties + s.Services = decoded.Services + s.Status = decoded.Status + s.Tags = decoded.Tags + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling CommandJob into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["distribution"]; ok { + impl, err := UnmarshalDistributionConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Distribution' for 'CommandJob': %+v", err) + } + s.Distribution = impl + } + + if v, ok := temp["identity"]; ok { + impl, err := UnmarshalIdentityConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Identity' for 'CommandJob': %+v", err) + } + s.Identity = impl + } + + if v, ok := temp["inputs"]; ok { + var dictionaryTemp map[string]json.RawMessage + if err := json.Unmarshal(v, &dictionaryTemp); err != nil { + return fmt.Errorf("unmarshaling Inputs into dictionary map[string]json.RawMessage: %+v", err) + } + + output := make(map[string]JobInput) + for key, val := range dictionaryTemp { + impl, err := UnmarshalJobInputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling key %q field 'Inputs' for 'CommandJob': %+v", key, err) + } + output[key] = impl + } + s.Inputs = &output + } + + if v, ok := temp["limits"]; ok { + impl, err := UnmarshalJobLimitsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Limits' for 'CommandJob': %+v", err) + } + s.Limits = impl + } + + if v, ok := temp["outputs"]; ok { + var dictionaryTemp map[string]json.RawMessage + if err := json.Unmarshal(v, &dictionaryTemp); err != nil { + return fmt.Errorf("unmarshaling Outputs into dictionary map[string]json.RawMessage: %+v", err) + } + + output := make(map[string]JobOutput) + for key, val := range dictionaryTemp { + impl, err := UnmarshalJobOutputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling key %q field 'Outputs' for 'CommandJob': %+v", key, err) + } + output[key] = impl + } + s.Outputs = &output + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_commandjoblimits.go b/resource-manager/machinelearningservices/2025-04-01/job/model_commandjoblimits.go new file mode 100644 index 00000000000..0d2c4f89460 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_commandjoblimits.go @@ -0,0 +1,51 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobLimits = CommandJobLimits{} + +type CommandJobLimits struct { + + // Fields inherited from JobLimits + + JobLimitsType JobLimitsType `json:"jobLimitsType"` + Timeout *string `json:"timeout,omitempty"` +} + +func (s CommandJobLimits) JobLimits() BaseJobLimitsImpl { + return BaseJobLimitsImpl{ + JobLimitsType: s.JobLimitsType, + Timeout: s.Timeout, + } +} + +var _ json.Marshaler = CommandJobLimits{} + +func (s CommandJobLimits) MarshalJSON() ([]byte, error) { + type wrapper CommandJobLimits + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CommandJobLimits: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CommandJobLimits: %+v", err) + } + + decoded["jobLimitsType"] = "Command" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CommandJobLimits: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_customforecasthorizon.go b/resource-manager/machinelearningservices/2025-04-01/job/model_customforecasthorizon.go new file mode 100644 index 00000000000..e04e41308fd --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_customforecasthorizon.go @@ -0,0 +1,50 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ForecastHorizon = CustomForecastHorizon{} + +type CustomForecastHorizon struct { + Value int64 `json:"value"` + + // Fields inherited from ForecastHorizon + + Mode ForecastHorizonMode `json:"mode"` +} + +func (s CustomForecastHorizon) ForecastHorizon() BaseForecastHorizonImpl { + return BaseForecastHorizonImpl{ + Mode: s.Mode, + } +} + +var _ json.Marshaler = CustomForecastHorizon{} + +func (s CustomForecastHorizon) MarshalJSON() ([]byte, error) { + type wrapper CustomForecastHorizon + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CustomForecastHorizon: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CustomForecastHorizon: %+v", err) + } + + decoded["mode"] = "Custom" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CustomForecastHorizon: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_custommodeljobinput.go b/resource-manager/machinelearningservices/2025-04-01/job/model_custommodeljobinput.go new file mode 100644 index 00000000000..beb41ad4fed --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_custommodeljobinput.go @@ -0,0 +1,53 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobInput = CustomModelJobInput{} + +type CustomModelJobInput struct { + Mode *InputDeliveryMode `json:"mode,omitempty"` + Uri string `json:"uri"` + + // Fields inherited from JobInput + + Description *string `json:"description,omitempty"` + JobInputType JobInputType `json:"jobInputType"` +} + +func (s CustomModelJobInput) JobInput() BaseJobInputImpl { + return BaseJobInputImpl{ + Description: s.Description, + JobInputType: s.JobInputType, + } +} + +var _ json.Marshaler = CustomModelJobInput{} + +func (s CustomModelJobInput) MarshalJSON() ([]byte, error) { + type wrapper CustomModelJobInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CustomModelJobInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CustomModelJobInput: %+v", err) + } + + decoded["jobInputType"] = "custom_model" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CustomModelJobInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_custommodeljoboutput.go b/resource-manager/machinelearningservices/2025-04-01/job/model_custommodeljoboutput.go new file mode 100644 index 00000000000..eedce78f9d2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_custommodeljoboutput.go @@ -0,0 +1,53 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobOutput = CustomModelJobOutput{} + +type CustomModelJobOutput struct { + Mode *OutputDeliveryMode `json:"mode,omitempty"` + Uri *string `json:"uri,omitempty"` + + // Fields inherited from JobOutput + + Description *string `json:"description,omitempty"` + JobOutputType JobOutputType `json:"jobOutputType"` +} + +func (s CustomModelJobOutput) JobOutput() BaseJobOutputImpl { + return BaseJobOutputImpl{ + Description: s.Description, + JobOutputType: s.JobOutputType, + } +} + +var _ json.Marshaler = CustomModelJobOutput{} + +func (s CustomModelJobOutput) MarshalJSON() ([]byte, error) { + type wrapper CustomModelJobOutput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CustomModelJobOutput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CustomModelJobOutput: %+v", err) + } + + decoded["jobOutputType"] = "custom_model" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CustomModelJobOutput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_customncrossvalidations.go b/resource-manager/machinelearningservices/2025-04-01/job/model_customncrossvalidations.go new file mode 100644 index 00000000000..730a631f5b2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_customncrossvalidations.go @@ -0,0 +1,50 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ NCrossValidations = CustomNCrossValidations{} + +type CustomNCrossValidations struct { + Value int64 `json:"value"` + + // Fields inherited from NCrossValidations + + Mode NCrossValidationsMode `json:"mode"` +} + +func (s CustomNCrossValidations) NCrossValidations() BaseNCrossValidationsImpl { + return BaseNCrossValidationsImpl{ + Mode: s.Mode, + } +} + +var _ json.Marshaler = CustomNCrossValidations{} + +func (s CustomNCrossValidations) MarshalJSON() ([]byte, error) { + type wrapper CustomNCrossValidations + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CustomNCrossValidations: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CustomNCrossValidations: %+v", err) + } + + decoded["mode"] = "Custom" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CustomNCrossValidations: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_customseasonality.go b/resource-manager/machinelearningservices/2025-04-01/job/model_customseasonality.go new file mode 100644 index 00000000000..c86016bdecd --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_customseasonality.go @@ -0,0 +1,50 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Seasonality = CustomSeasonality{} + +type CustomSeasonality struct { + Value int64 `json:"value"` + + // Fields inherited from Seasonality + + Mode SeasonalityMode `json:"mode"` +} + +func (s CustomSeasonality) Seasonality() BaseSeasonalityImpl { + return BaseSeasonalityImpl{ + Mode: s.Mode, + } +} + +var _ json.Marshaler = CustomSeasonality{} + +func (s CustomSeasonality) MarshalJSON() ([]byte, error) { + type wrapper CustomSeasonality + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CustomSeasonality: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CustomSeasonality: %+v", err) + } + + decoded["mode"] = "Custom" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CustomSeasonality: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_customtargetlags.go b/resource-manager/machinelearningservices/2025-04-01/job/model_customtargetlags.go new file mode 100644 index 00000000000..da1661ae7d5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_customtargetlags.go @@ -0,0 +1,50 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TargetLags = CustomTargetLags{} + +type CustomTargetLags struct { + Values []int64 `json:"values"` + + // Fields inherited from TargetLags + + Mode TargetLagsMode `json:"mode"` +} + +func (s CustomTargetLags) TargetLags() BaseTargetLagsImpl { + return BaseTargetLagsImpl{ + Mode: s.Mode, + } +} + +var _ json.Marshaler = CustomTargetLags{} + +func (s CustomTargetLags) MarshalJSON() ([]byte, error) { + type wrapper CustomTargetLags + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CustomTargetLags: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CustomTargetLags: %+v", err) + } + + decoded["mode"] = "Custom" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CustomTargetLags: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_customtargetrollingwindowsize.go b/resource-manager/machinelearningservices/2025-04-01/job/model_customtargetrollingwindowsize.go new file mode 100644 index 00000000000..ac2fae417a6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_customtargetrollingwindowsize.go @@ -0,0 +1,50 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TargetRollingWindowSize = CustomTargetRollingWindowSize{} + +type CustomTargetRollingWindowSize struct { + Value int64 `json:"value"` + + // Fields inherited from TargetRollingWindowSize + + Mode TargetRollingWindowSizeMode `json:"mode"` +} + +func (s CustomTargetRollingWindowSize) TargetRollingWindowSize() BaseTargetRollingWindowSizeImpl { + return BaseTargetRollingWindowSizeImpl{ + Mode: s.Mode, + } +} + +var _ json.Marshaler = CustomTargetRollingWindowSize{} + +func (s CustomTargetRollingWindowSize) MarshalJSON() ([]byte, error) { + type wrapper CustomTargetRollingWindowSize + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CustomTargetRollingWindowSize: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CustomTargetRollingWindowSize: %+v", err) + } + + decoded["mode"] = "Custom" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CustomTargetRollingWindowSize: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_distributionconfiguration.go b/resource-manager/machinelearningservices/2025-04-01/job/model_distributionconfiguration.go new file mode 100644 index 00000000000..4b9603b3dca --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_distributionconfiguration.go @@ -0,0 +1,91 @@ +package job + +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 DistributionConfiguration interface { + DistributionConfiguration() BaseDistributionConfigurationImpl +} + +var _ DistributionConfiguration = BaseDistributionConfigurationImpl{} + +type BaseDistributionConfigurationImpl struct { + DistributionType DistributionType `json:"distributionType"` +} + +func (s BaseDistributionConfigurationImpl) DistributionConfiguration() BaseDistributionConfigurationImpl { + return s +} + +var _ DistributionConfiguration = RawDistributionConfigurationImpl{} + +// RawDistributionConfigurationImpl 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 RawDistributionConfigurationImpl struct { + distributionConfiguration BaseDistributionConfigurationImpl + Type string + Values map[string]interface{} +} + +func (s RawDistributionConfigurationImpl) DistributionConfiguration() BaseDistributionConfigurationImpl { + return s.distributionConfiguration +} + +func UnmarshalDistributionConfigurationImplementation(input []byte) (DistributionConfiguration, 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 DistributionConfiguration into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["distributionType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Mpi") { + var out Mpi + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into Mpi: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "PyTorch") { + var out PyTorch + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into PyTorch: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "TensorFlow") { + var out TensorFlow + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into TensorFlow: %+v", err) + } + return out, nil + } + + var parent BaseDistributionConfigurationImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseDistributionConfigurationImpl: %+v", err) + } + + return RawDistributionConfigurationImpl{ + distributionConfiguration: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_earlyterminationpolicy.go b/resource-manager/machinelearningservices/2025-04-01/job/model_earlyterminationpolicy.go new file mode 100644 index 00000000000..201e43c3708 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_earlyterminationpolicy.go @@ -0,0 +1,93 @@ +package job + +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 EarlyTerminationPolicy interface { + EarlyTerminationPolicy() BaseEarlyTerminationPolicyImpl +} + +var _ EarlyTerminationPolicy = BaseEarlyTerminationPolicyImpl{} + +type BaseEarlyTerminationPolicyImpl struct { + DelayEvaluation *int64 `json:"delayEvaluation,omitempty"` + EvaluationInterval *int64 `json:"evaluationInterval,omitempty"` + PolicyType EarlyTerminationPolicyType `json:"policyType"` +} + +func (s BaseEarlyTerminationPolicyImpl) EarlyTerminationPolicy() BaseEarlyTerminationPolicyImpl { + return s +} + +var _ EarlyTerminationPolicy = RawEarlyTerminationPolicyImpl{} + +// RawEarlyTerminationPolicyImpl 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 RawEarlyTerminationPolicyImpl struct { + earlyTerminationPolicy BaseEarlyTerminationPolicyImpl + Type string + Values map[string]interface{} +} + +func (s RawEarlyTerminationPolicyImpl) EarlyTerminationPolicy() BaseEarlyTerminationPolicyImpl { + return s.earlyTerminationPolicy +} + +func UnmarshalEarlyTerminationPolicyImplementation(input []byte) (EarlyTerminationPolicy, 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 EarlyTerminationPolicy into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["policyType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Bandit") { + var out BanditPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into BanditPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "MedianStopping") { + var out MedianStoppingPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MedianStoppingPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "TruncationSelection") { + var out TruncationSelectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into TruncationSelectionPolicy: %+v", err) + } + return out, nil + } + + var parent BaseEarlyTerminationPolicyImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseEarlyTerminationPolicyImpl: %+v", err) + } + + return RawEarlyTerminationPolicyImpl{ + earlyTerminationPolicy: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_featurizationsettings.go b/resource-manager/machinelearningservices/2025-04-01/job/model_featurizationsettings.go new file mode 100644 index 00000000000..5d820370a15 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_featurizationsettings.go @@ -0,0 +1,8 @@ +package job + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FeaturizationSettings struct { + DatasetLanguage *string `json:"datasetLanguage,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_forecasthorizon.go b/resource-manager/machinelearningservices/2025-04-01/job/model_forecasthorizon.go new file mode 100644 index 00000000000..d65408f8783 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_forecasthorizon.go @@ -0,0 +1,83 @@ +package job + +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 ForecastHorizon interface { + ForecastHorizon() BaseForecastHorizonImpl +} + +var _ ForecastHorizon = BaseForecastHorizonImpl{} + +type BaseForecastHorizonImpl struct { + Mode ForecastHorizonMode `json:"mode"` +} + +func (s BaseForecastHorizonImpl) ForecastHorizon() BaseForecastHorizonImpl { + return s +} + +var _ ForecastHorizon = RawForecastHorizonImpl{} + +// RawForecastHorizonImpl 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 RawForecastHorizonImpl struct { + forecastHorizon BaseForecastHorizonImpl + Type string + Values map[string]interface{} +} + +func (s RawForecastHorizonImpl) ForecastHorizon() BaseForecastHorizonImpl { + return s.forecastHorizon +} + +func UnmarshalForecastHorizonImplementation(input []byte) (ForecastHorizon, 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 ForecastHorizon into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["mode"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Auto") { + var out AutoForecastHorizon + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AutoForecastHorizon: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Custom") { + var out CustomForecastHorizon + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CustomForecastHorizon: %+v", err) + } + return out, nil + } + + var parent BaseForecastHorizonImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseForecastHorizonImpl: %+v", err) + } + + return RawForecastHorizonImpl{ + forecastHorizon: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_forecasting.go b/resource-manager/machinelearningservices/2025-04-01/job/model_forecasting.go new file mode 100644 index 00000000000..af3bc2bcb7f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_forecasting.go @@ -0,0 +1,123 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AutoMLVertical = Forecasting{} + +type Forecasting struct { + CvSplitColumnNames *[]string `json:"cvSplitColumnNames,omitempty"` + FeaturizationSettings *TableVerticalFeaturizationSettings `json:"featurizationSettings,omitempty"` + ForecastingSettings *ForecastingSettings `json:"forecastingSettings,omitempty"` + LimitSettings *TableVerticalLimitSettings `json:"limitSettings,omitempty"` + NCrossValidations NCrossValidations `json:"nCrossValidations"` + PrimaryMetric *ForecastingPrimaryMetrics `json:"primaryMetric,omitempty"` + TestData *MLTableJobInput `json:"testData,omitempty"` + TestDataSize *float64 `json:"testDataSize,omitempty"` + TrainingSettings *ForecastingTrainingSettings `json:"trainingSettings,omitempty"` + ValidationData *MLTableJobInput `json:"validationData,omitempty"` + ValidationDataSize *float64 `json:"validationDataSize,omitempty"` + WeightColumnName *string `json:"weightColumnName,omitempty"` + + // Fields inherited from AutoMLVertical + + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` +} + +func (s Forecasting) AutoMLVertical() BaseAutoMLVerticalImpl { + return BaseAutoMLVerticalImpl{ + LogVerbosity: s.LogVerbosity, + TargetColumnName: s.TargetColumnName, + TaskType: s.TaskType, + TrainingData: s.TrainingData, + } +} + +var _ json.Marshaler = Forecasting{} + +func (s Forecasting) MarshalJSON() ([]byte, error) { + type wrapper Forecasting + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling Forecasting: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling Forecasting: %+v", err) + } + + decoded["taskType"] = "Forecasting" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling Forecasting: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &Forecasting{} + +func (s *Forecasting) UnmarshalJSON(bytes []byte) error { + var decoded struct { + CvSplitColumnNames *[]string `json:"cvSplitColumnNames,omitempty"` + FeaturizationSettings *TableVerticalFeaturizationSettings `json:"featurizationSettings,omitempty"` + ForecastingSettings *ForecastingSettings `json:"forecastingSettings,omitempty"` + LimitSettings *TableVerticalLimitSettings `json:"limitSettings,omitempty"` + PrimaryMetric *ForecastingPrimaryMetrics `json:"primaryMetric,omitempty"` + TestData *MLTableJobInput `json:"testData,omitempty"` + TestDataSize *float64 `json:"testDataSize,omitempty"` + TrainingSettings *ForecastingTrainingSettings `json:"trainingSettings,omitempty"` + ValidationData *MLTableJobInput `json:"validationData,omitempty"` + ValidationDataSize *float64 `json:"validationDataSize,omitempty"` + WeightColumnName *string `json:"weightColumnName,omitempty"` + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.CvSplitColumnNames = decoded.CvSplitColumnNames + s.FeaturizationSettings = decoded.FeaturizationSettings + s.ForecastingSettings = decoded.ForecastingSettings + s.LimitSettings = decoded.LimitSettings + s.PrimaryMetric = decoded.PrimaryMetric + s.TestData = decoded.TestData + s.TestDataSize = decoded.TestDataSize + s.TrainingSettings = decoded.TrainingSettings + s.ValidationData = decoded.ValidationData + s.ValidationDataSize = decoded.ValidationDataSize + s.WeightColumnName = decoded.WeightColumnName + s.LogVerbosity = decoded.LogVerbosity + s.TargetColumnName = decoded.TargetColumnName + s.TaskType = decoded.TaskType + s.TrainingData = decoded.TrainingData + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling Forecasting into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["nCrossValidations"]; ok { + impl, err := UnmarshalNCrossValidationsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'NCrossValidations' for 'Forecasting': %+v", err) + } + s.NCrossValidations = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_forecastingsettings.go b/resource-manager/machinelearningservices/2025-04-01/job/model_forecastingsettings.go new file mode 100644 index 00000000000..2ea046496b7 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_forecastingsettings.go @@ -0,0 +1,93 @@ +package job + +import ( + "encoding/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 ForecastingSettings struct { + CountryOrRegionForHolidays *string `json:"countryOrRegionForHolidays,omitempty"` + CvStepSize *int64 `json:"cvStepSize,omitempty"` + FeatureLags *FeatureLags `json:"featureLags,omitempty"` + ForecastHorizon ForecastHorizon `json:"forecastHorizon"` + Frequency *string `json:"frequency,omitempty"` + Seasonality Seasonality `json:"seasonality"` + ShortSeriesHandlingConfig *ShortSeriesHandlingConfiguration `json:"shortSeriesHandlingConfig,omitempty"` + TargetAggregateFunction *TargetAggregationFunction `json:"targetAggregateFunction,omitempty"` + TargetLags TargetLags `json:"targetLags"` + TargetRollingWindowSize TargetRollingWindowSize `json:"targetRollingWindowSize"` + TimeColumnName *string `json:"timeColumnName,omitempty"` + TimeSeriesIdColumnNames *[]string `json:"timeSeriesIdColumnNames,omitempty"` + UseStl *UseStl `json:"useStl,omitempty"` +} + +var _ json.Unmarshaler = &ForecastingSettings{} + +func (s *ForecastingSettings) UnmarshalJSON(bytes []byte) error { + var decoded struct { + CountryOrRegionForHolidays *string `json:"countryOrRegionForHolidays,omitempty"` + CvStepSize *int64 `json:"cvStepSize,omitempty"` + FeatureLags *FeatureLags `json:"featureLags,omitempty"` + Frequency *string `json:"frequency,omitempty"` + ShortSeriesHandlingConfig *ShortSeriesHandlingConfiguration `json:"shortSeriesHandlingConfig,omitempty"` + TargetAggregateFunction *TargetAggregationFunction `json:"targetAggregateFunction,omitempty"` + TimeColumnName *string `json:"timeColumnName,omitempty"` + TimeSeriesIdColumnNames *[]string `json:"timeSeriesIdColumnNames,omitempty"` + UseStl *UseStl `json:"useStl,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.CountryOrRegionForHolidays = decoded.CountryOrRegionForHolidays + s.CvStepSize = decoded.CvStepSize + s.FeatureLags = decoded.FeatureLags + s.Frequency = decoded.Frequency + s.ShortSeriesHandlingConfig = decoded.ShortSeriesHandlingConfig + s.TargetAggregateFunction = decoded.TargetAggregateFunction + s.TimeColumnName = decoded.TimeColumnName + s.TimeSeriesIdColumnNames = decoded.TimeSeriesIdColumnNames + s.UseStl = decoded.UseStl + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ForecastingSettings into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["forecastHorizon"]; ok { + impl, err := UnmarshalForecastHorizonImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ForecastHorizon' for 'ForecastingSettings': %+v", err) + } + s.ForecastHorizon = impl + } + + if v, ok := temp["seasonality"]; ok { + impl, err := UnmarshalSeasonalityImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Seasonality' for 'ForecastingSettings': %+v", err) + } + s.Seasonality = impl + } + + if v, ok := temp["targetLags"]; ok { + impl, err := UnmarshalTargetLagsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'TargetLags' for 'ForecastingSettings': %+v", err) + } + s.TargetLags = impl + } + + if v, ok := temp["targetRollingWindowSize"]; ok { + impl, err := UnmarshalTargetRollingWindowSizeImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'TargetRollingWindowSize' for 'ForecastingSettings': %+v", err) + } + s.TargetRollingWindowSize = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_forecastingtrainingsettings.go b/resource-manager/machinelearningservices/2025-04-01/job/model_forecastingtrainingsettings.go new file mode 100644 index 00000000000..8e025075307 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_forecastingtrainingsettings.go @@ -0,0 +1,16 @@ +package job + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ForecastingTrainingSettings struct { + AllowedTrainingAlgorithms *[]ForecastingModels `json:"allowedTrainingAlgorithms,omitempty"` + BlockedTrainingAlgorithms *[]ForecastingModels `json:"blockedTrainingAlgorithms,omitempty"` + EnableDnnTraining *bool `json:"enableDnnTraining,omitempty"` + EnableModelExplainability *bool `json:"enableModelExplainability,omitempty"` + EnableOnnxCompatibleModels *bool `json:"enableOnnxCompatibleModels,omitempty"` + EnableStackEnsemble *bool `json:"enableStackEnsemble,omitempty"` + EnableVoteEnsemble *bool `json:"enableVoteEnsemble,omitempty"` + EnsembleModelDownloadTimeout *string `json:"ensembleModelDownloadTimeout,omitempty"` + StackEnsembleSettings *StackEnsembleSettings `json:"stackEnsembleSettings,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_gridsamplingalgorithm.go b/resource-manager/machinelearningservices/2025-04-01/job/model_gridsamplingalgorithm.go new file mode 100644 index 00000000000..491e4b359b0 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_gridsamplingalgorithm.go @@ -0,0 +1,49 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SamplingAlgorithm = GridSamplingAlgorithm{} + +type GridSamplingAlgorithm struct { + + // Fields inherited from SamplingAlgorithm + + SamplingAlgorithmType SamplingAlgorithmType `json:"samplingAlgorithmType"` +} + +func (s GridSamplingAlgorithm) SamplingAlgorithm() BaseSamplingAlgorithmImpl { + return BaseSamplingAlgorithmImpl{ + SamplingAlgorithmType: s.SamplingAlgorithmType, + } +} + +var _ json.Marshaler = GridSamplingAlgorithm{} + +func (s GridSamplingAlgorithm) MarshalJSON() ([]byte, error) { + type wrapper GridSamplingAlgorithm + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GridSamplingAlgorithm: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GridSamplingAlgorithm: %+v", err) + } + + decoded["samplingAlgorithmType"] = "Grid" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GridSamplingAlgorithm: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_identityconfiguration.go b/resource-manager/machinelearningservices/2025-04-01/job/model_identityconfiguration.go new file mode 100644 index 00000000000..d04f73405c6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_identityconfiguration.go @@ -0,0 +1,91 @@ +package job + +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 IdentityConfiguration interface { + IdentityConfiguration() BaseIdentityConfigurationImpl +} + +var _ IdentityConfiguration = BaseIdentityConfigurationImpl{} + +type BaseIdentityConfigurationImpl struct { + IdentityType IdentityConfigurationType `json:"identityType"` +} + +func (s BaseIdentityConfigurationImpl) IdentityConfiguration() BaseIdentityConfigurationImpl { + return s +} + +var _ IdentityConfiguration = RawIdentityConfigurationImpl{} + +// RawIdentityConfigurationImpl 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 RawIdentityConfigurationImpl struct { + identityConfiguration BaseIdentityConfigurationImpl + Type string + Values map[string]interface{} +} + +func (s RawIdentityConfigurationImpl) IdentityConfiguration() BaseIdentityConfigurationImpl { + return s.identityConfiguration +} + +func UnmarshalIdentityConfigurationImplementation(input []byte) (IdentityConfiguration, 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 IdentityConfiguration into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["identityType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AMLToken") { + var out AmlToken + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AmlToken: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Managed") { + var out ManagedIdentity + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ManagedIdentity: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "UserIdentity") { + var out UserIdentity + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into UserIdentity: %+v", err) + } + return out, nil + } + + var parent BaseIdentityConfigurationImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseIdentityConfigurationImpl: %+v", err) + } + + return RawIdentityConfigurationImpl{ + identityConfiguration: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_imageclassification.go b/resource-manager/machinelearningservices/2025-04-01/job/model_imageclassification.go new file mode 100644 index 00000000000..fbab861e4e2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_imageclassification.go @@ -0,0 +1,62 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AutoMLVertical = ImageClassification{} + +type ImageClassification struct { + LimitSettings ImageLimitSettings `json:"limitSettings"` + ModelSettings *ImageModelSettingsClassification `json:"modelSettings,omitempty"` + PrimaryMetric *ClassificationPrimaryMetrics `json:"primaryMetric,omitempty"` + SearchSpace *[]ImageModelDistributionSettingsClassification `json:"searchSpace,omitempty"` + SweepSettings *ImageSweepSettings `json:"sweepSettings,omitempty"` + ValidationData *MLTableJobInput `json:"validationData,omitempty"` + ValidationDataSize *float64 `json:"validationDataSize,omitempty"` + + // Fields inherited from AutoMLVertical + + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` +} + +func (s ImageClassification) AutoMLVertical() BaseAutoMLVerticalImpl { + return BaseAutoMLVerticalImpl{ + LogVerbosity: s.LogVerbosity, + TargetColumnName: s.TargetColumnName, + TaskType: s.TaskType, + TrainingData: s.TrainingData, + } +} + +var _ json.Marshaler = ImageClassification{} + +func (s ImageClassification) MarshalJSON() ([]byte, error) { + type wrapper ImageClassification + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ImageClassification: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ImageClassification: %+v", err) + } + + decoded["taskType"] = "ImageClassification" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ImageClassification: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_imageclassificationmultilabel.go b/resource-manager/machinelearningservices/2025-04-01/job/model_imageclassificationmultilabel.go new file mode 100644 index 00000000000..c40ef97601b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_imageclassificationmultilabel.go @@ -0,0 +1,62 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AutoMLVertical = ImageClassificationMultilabel{} + +type ImageClassificationMultilabel struct { + LimitSettings ImageLimitSettings `json:"limitSettings"` + ModelSettings *ImageModelSettingsClassification `json:"modelSettings,omitempty"` + PrimaryMetric *ClassificationMultilabelPrimaryMetrics `json:"primaryMetric,omitempty"` + SearchSpace *[]ImageModelDistributionSettingsClassification `json:"searchSpace,omitempty"` + SweepSettings *ImageSweepSettings `json:"sweepSettings,omitempty"` + ValidationData *MLTableJobInput `json:"validationData,omitempty"` + ValidationDataSize *float64 `json:"validationDataSize,omitempty"` + + // Fields inherited from AutoMLVertical + + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` +} + +func (s ImageClassificationMultilabel) AutoMLVertical() BaseAutoMLVerticalImpl { + return BaseAutoMLVerticalImpl{ + LogVerbosity: s.LogVerbosity, + TargetColumnName: s.TargetColumnName, + TaskType: s.TaskType, + TrainingData: s.TrainingData, + } +} + +var _ json.Marshaler = ImageClassificationMultilabel{} + +func (s ImageClassificationMultilabel) MarshalJSON() ([]byte, error) { + type wrapper ImageClassificationMultilabel + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ImageClassificationMultilabel: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ImageClassificationMultilabel: %+v", err) + } + + decoded["taskType"] = "ImageClassificationMultilabel" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ImageClassificationMultilabel: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_imageinstancesegmentation.go b/resource-manager/machinelearningservices/2025-04-01/job/model_imageinstancesegmentation.go new file mode 100644 index 00000000000..b878e99a9cb --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_imageinstancesegmentation.go @@ -0,0 +1,62 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AutoMLVertical = ImageInstanceSegmentation{} + +type ImageInstanceSegmentation struct { + LimitSettings ImageLimitSettings `json:"limitSettings"` + ModelSettings *ImageModelSettingsObjectDetection `json:"modelSettings,omitempty"` + PrimaryMetric *InstanceSegmentationPrimaryMetrics `json:"primaryMetric,omitempty"` + SearchSpace *[]ImageModelDistributionSettingsObjectDetection `json:"searchSpace,omitempty"` + SweepSettings *ImageSweepSettings `json:"sweepSettings,omitempty"` + ValidationData *MLTableJobInput `json:"validationData,omitempty"` + ValidationDataSize *float64 `json:"validationDataSize,omitempty"` + + // Fields inherited from AutoMLVertical + + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` +} + +func (s ImageInstanceSegmentation) AutoMLVertical() BaseAutoMLVerticalImpl { + return BaseAutoMLVerticalImpl{ + LogVerbosity: s.LogVerbosity, + TargetColumnName: s.TargetColumnName, + TaskType: s.TaskType, + TrainingData: s.TrainingData, + } +} + +var _ json.Marshaler = ImageInstanceSegmentation{} + +func (s ImageInstanceSegmentation) MarshalJSON() ([]byte, error) { + type wrapper ImageInstanceSegmentation + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ImageInstanceSegmentation: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ImageInstanceSegmentation: %+v", err) + } + + decoded["taskType"] = "ImageInstanceSegmentation" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ImageInstanceSegmentation: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_imagelimitsettings.go b/resource-manager/machinelearningservices/2025-04-01/job/model_imagelimitsettings.go new file mode 100644 index 00000000000..6755002af74 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_imagelimitsettings.go @@ -0,0 +1,10 @@ +package job + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImageLimitSettings struct { + MaxConcurrentTrials *int64 `json:"maxConcurrentTrials,omitempty"` + MaxTrials *int64 `json:"maxTrials,omitempty"` + Timeout *string `json:"timeout,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_imagemodeldistributionsettingsclassification.go b/resource-manager/machinelearningservices/2025-04-01/job/model_imagemodeldistributionsettingsclassification.go new file mode 100644 index 00000000000..d3546b6e1c9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_imagemodeldistributionsettingsclassification.go @@ -0,0 +1,39 @@ +package job + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImageModelDistributionSettingsClassification struct { + AmsGradient *string `json:"amsGradient,omitempty"` + Augmentations *string `json:"augmentations,omitempty"` + Beta1 *string `json:"beta1,omitempty"` + Beta2 *string `json:"beta2,omitempty"` + Distributed *string `json:"distributed,omitempty"` + EarlyStopping *string `json:"earlyStopping,omitempty"` + EarlyStoppingDelay *string `json:"earlyStoppingDelay,omitempty"` + EarlyStoppingPatience *string `json:"earlyStoppingPatience,omitempty"` + EnableOnnxNormalization *string `json:"enableOnnxNormalization,omitempty"` + EvaluationFrequency *string `json:"evaluationFrequency,omitempty"` + GradientAccumulationStep *string `json:"gradientAccumulationStep,omitempty"` + LayersToFreeze *string `json:"layersToFreeze,omitempty"` + LearningRate *string `json:"learningRate,omitempty"` + LearningRateScheduler *string `json:"learningRateScheduler,omitempty"` + ModelName *string `json:"modelName,omitempty"` + Momentum *string `json:"momentum,omitempty"` + Nesterov *string `json:"nesterov,omitempty"` + NumberOfEpochs *string `json:"numberOfEpochs,omitempty"` + NumberOfWorkers *string `json:"numberOfWorkers,omitempty"` + Optimizer *string `json:"optimizer,omitempty"` + RandomSeed *string `json:"randomSeed,omitempty"` + StepLRGamma *string `json:"stepLRGamma,omitempty"` + StepLRStepSize *string `json:"stepLRStepSize,omitempty"` + TrainingBatchSize *string `json:"trainingBatchSize,omitempty"` + TrainingCropSize *string `json:"trainingCropSize,omitempty"` + ValidationBatchSize *string `json:"validationBatchSize,omitempty"` + ValidationCropSize *string `json:"validationCropSize,omitempty"` + ValidationResizeSize *string `json:"validationResizeSize,omitempty"` + WarmupCosineLRCycles *string `json:"warmupCosineLRCycles,omitempty"` + WarmupCosineLRWarmupEpochs *string `json:"warmupCosineLRWarmupEpochs,omitempty"` + WeightDecay *string `json:"weightDecay,omitempty"` + WeightedLoss *string `json:"weightedLoss,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_imagemodeldistributionsettingsobjectdetection.go b/resource-manager/machinelearningservices/2025-04-01/job/model_imagemodeldistributionsettingsobjectdetection.go new file mode 100644 index 00000000000..bdae5458f10 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_imagemodeldistributionsettingsobjectdetection.go @@ -0,0 +1,48 @@ +package job + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImageModelDistributionSettingsObjectDetection struct { + AmsGradient *string `json:"amsGradient,omitempty"` + Augmentations *string `json:"augmentations,omitempty"` + Beta1 *string `json:"beta1,omitempty"` + Beta2 *string `json:"beta2,omitempty"` + BoxDetectionsPerImage *string `json:"boxDetectionsPerImage,omitempty"` + BoxScoreThreshold *string `json:"boxScoreThreshold,omitempty"` + Distributed *string `json:"distributed,omitempty"` + EarlyStopping *string `json:"earlyStopping,omitempty"` + EarlyStoppingDelay *string `json:"earlyStoppingDelay,omitempty"` + EarlyStoppingPatience *string `json:"earlyStoppingPatience,omitempty"` + EnableOnnxNormalization *string `json:"enableOnnxNormalization,omitempty"` + EvaluationFrequency *string `json:"evaluationFrequency,omitempty"` + GradientAccumulationStep *string `json:"gradientAccumulationStep,omitempty"` + ImageSize *string `json:"imageSize,omitempty"` + LayersToFreeze *string `json:"layersToFreeze,omitempty"` + LearningRate *string `json:"learningRate,omitempty"` + LearningRateScheduler *string `json:"learningRateScheduler,omitempty"` + MaxSize *string `json:"maxSize,omitempty"` + MinSize *string `json:"minSize,omitempty"` + ModelName *string `json:"modelName,omitempty"` + ModelSize *string `json:"modelSize,omitempty"` + Momentum *string `json:"momentum,omitempty"` + MultiScale *string `json:"multiScale,omitempty"` + Nesterov *string `json:"nesterov,omitempty"` + NmsIouThreshold *string `json:"nmsIouThreshold,omitempty"` + NumberOfEpochs *string `json:"numberOfEpochs,omitempty"` + NumberOfWorkers *string `json:"numberOfWorkers,omitempty"` + Optimizer *string `json:"optimizer,omitempty"` + RandomSeed *string `json:"randomSeed,omitempty"` + StepLRGamma *string `json:"stepLRGamma,omitempty"` + StepLRStepSize *string `json:"stepLRStepSize,omitempty"` + TileGridSize *string `json:"tileGridSize,omitempty"` + TileOverlapRatio *string `json:"tileOverlapRatio,omitempty"` + TilePredictionsNmsThreshold *string `json:"tilePredictionsNmsThreshold,omitempty"` + TrainingBatchSize *string `json:"trainingBatchSize,omitempty"` + ValidationBatchSize *string `json:"validationBatchSize,omitempty"` + ValidationIouThreshold *string `json:"validationIouThreshold,omitempty"` + ValidationMetricType *string `json:"validationMetricType,omitempty"` + WarmupCosineLRCycles *string `json:"warmupCosineLRCycles,omitempty"` + WarmupCosineLRWarmupEpochs *string `json:"warmupCosineLRWarmupEpochs,omitempty"` + WeightDecay *string `json:"weightDecay,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_imagemodelsettingsclassification.go b/resource-manager/machinelearningservices/2025-04-01/job/model_imagemodelsettingsclassification.go new file mode 100644 index 00000000000..24f5c7af1f3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_imagemodelsettingsclassification.go @@ -0,0 +1,43 @@ +package job + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImageModelSettingsClassification struct { + AdvancedSettings *string `json:"advancedSettings,omitempty"` + AmsGradient *bool `json:"amsGradient,omitempty"` + Augmentations *string `json:"augmentations,omitempty"` + Beta1 *float64 `json:"beta1,omitempty"` + Beta2 *float64 `json:"beta2,omitempty"` + CheckpointFrequency *int64 `json:"checkpointFrequency,omitempty"` + CheckpointModel *MLFlowModelJobInput `json:"checkpointModel,omitempty"` + CheckpointRunId *string `json:"checkpointRunId,omitempty"` + Distributed *bool `json:"distributed,omitempty"` + EarlyStopping *bool `json:"earlyStopping,omitempty"` + EarlyStoppingDelay *int64 `json:"earlyStoppingDelay,omitempty"` + EarlyStoppingPatience *int64 `json:"earlyStoppingPatience,omitempty"` + EnableOnnxNormalization *bool `json:"enableOnnxNormalization,omitempty"` + EvaluationFrequency *int64 `json:"evaluationFrequency,omitempty"` + GradientAccumulationStep *int64 `json:"gradientAccumulationStep,omitempty"` + LayersToFreeze *int64 `json:"layersToFreeze,omitempty"` + LearningRate *float64 `json:"learningRate,omitempty"` + LearningRateScheduler *LearningRateScheduler `json:"learningRateScheduler,omitempty"` + ModelName *string `json:"modelName,omitempty"` + Momentum *float64 `json:"momentum,omitempty"` + Nesterov *bool `json:"nesterov,omitempty"` + NumberOfEpochs *int64 `json:"numberOfEpochs,omitempty"` + NumberOfWorkers *int64 `json:"numberOfWorkers,omitempty"` + Optimizer *StochasticOptimizer `json:"optimizer,omitempty"` + RandomSeed *int64 `json:"randomSeed,omitempty"` + StepLRGamma *float64 `json:"stepLRGamma,omitempty"` + StepLRStepSize *int64 `json:"stepLRStepSize,omitempty"` + TrainingBatchSize *int64 `json:"trainingBatchSize,omitempty"` + TrainingCropSize *int64 `json:"trainingCropSize,omitempty"` + ValidationBatchSize *int64 `json:"validationBatchSize,omitempty"` + ValidationCropSize *int64 `json:"validationCropSize,omitempty"` + ValidationResizeSize *int64 `json:"validationResizeSize,omitempty"` + WarmupCosineLRCycles *float64 `json:"warmupCosineLRCycles,omitempty"` + WarmupCosineLRWarmupEpochs *int64 `json:"warmupCosineLRWarmupEpochs,omitempty"` + WeightDecay *float64 `json:"weightDecay,omitempty"` + WeightedLoss *int64 `json:"weightedLoss,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_imagemodelsettingsobjectdetection.go b/resource-manager/machinelearningservices/2025-04-01/job/model_imagemodelsettingsobjectdetection.go new file mode 100644 index 00000000000..640e8e426e5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_imagemodelsettingsobjectdetection.go @@ -0,0 +1,52 @@ +package job + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImageModelSettingsObjectDetection struct { + AdvancedSettings *string `json:"advancedSettings,omitempty"` + AmsGradient *bool `json:"amsGradient,omitempty"` + Augmentations *string `json:"augmentations,omitempty"` + Beta1 *float64 `json:"beta1,omitempty"` + Beta2 *float64 `json:"beta2,omitempty"` + BoxDetectionsPerImage *int64 `json:"boxDetectionsPerImage,omitempty"` + BoxScoreThreshold *float64 `json:"boxScoreThreshold,omitempty"` + CheckpointFrequency *int64 `json:"checkpointFrequency,omitempty"` + CheckpointModel *MLFlowModelJobInput `json:"checkpointModel,omitempty"` + CheckpointRunId *string `json:"checkpointRunId,omitempty"` + Distributed *bool `json:"distributed,omitempty"` + EarlyStopping *bool `json:"earlyStopping,omitempty"` + EarlyStoppingDelay *int64 `json:"earlyStoppingDelay,omitempty"` + EarlyStoppingPatience *int64 `json:"earlyStoppingPatience,omitempty"` + EnableOnnxNormalization *bool `json:"enableOnnxNormalization,omitempty"` + EvaluationFrequency *int64 `json:"evaluationFrequency,omitempty"` + GradientAccumulationStep *int64 `json:"gradientAccumulationStep,omitempty"` + ImageSize *int64 `json:"imageSize,omitempty"` + LayersToFreeze *int64 `json:"layersToFreeze,omitempty"` + LearningRate *float64 `json:"learningRate,omitempty"` + LearningRateScheduler *LearningRateScheduler `json:"learningRateScheduler,omitempty"` + MaxSize *int64 `json:"maxSize,omitempty"` + MinSize *int64 `json:"minSize,omitempty"` + ModelName *string `json:"modelName,omitempty"` + ModelSize *ModelSize `json:"modelSize,omitempty"` + Momentum *float64 `json:"momentum,omitempty"` + MultiScale *bool `json:"multiScale,omitempty"` + Nesterov *bool `json:"nesterov,omitempty"` + NmsIouThreshold *float64 `json:"nmsIouThreshold,omitempty"` + NumberOfEpochs *int64 `json:"numberOfEpochs,omitempty"` + NumberOfWorkers *int64 `json:"numberOfWorkers,omitempty"` + Optimizer *StochasticOptimizer `json:"optimizer,omitempty"` + RandomSeed *int64 `json:"randomSeed,omitempty"` + StepLRGamma *float64 `json:"stepLRGamma,omitempty"` + StepLRStepSize *int64 `json:"stepLRStepSize,omitempty"` + TileGridSize *string `json:"tileGridSize,omitempty"` + TileOverlapRatio *float64 `json:"tileOverlapRatio,omitempty"` + TilePredictionsNmsThreshold *float64 `json:"tilePredictionsNmsThreshold,omitempty"` + TrainingBatchSize *int64 `json:"trainingBatchSize,omitempty"` + ValidationBatchSize *int64 `json:"validationBatchSize,omitempty"` + ValidationIouThreshold *float64 `json:"validationIouThreshold,omitempty"` + ValidationMetricType *ValidationMetricType `json:"validationMetricType,omitempty"` + WarmupCosineLRCycles *float64 `json:"warmupCosineLRCycles,omitempty"` + WarmupCosineLRWarmupEpochs *int64 `json:"warmupCosineLRWarmupEpochs,omitempty"` + WeightDecay *float64 `json:"weightDecay,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_imageobjectdetection.go b/resource-manager/machinelearningservices/2025-04-01/job/model_imageobjectdetection.go new file mode 100644 index 00000000000..bdec18ee6c6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_imageobjectdetection.go @@ -0,0 +1,62 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AutoMLVertical = ImageObjectDetection{} + +type ImageObjectDetection struct { + LimitSettings ImageLimitSettings `json:"limitSettings"` + ModelSettings *ImageModelSettingsObjectDetection `json:"modelSettings,omitempty"` + PrimaryMetric *ObjectDetectionPrimaryMetrics `json:"primaryMetric,omitempty"` + SearchSpace *[]ImageModelDistributionSettingsObjectDetection `json:"searchSpace,omitempty"` + SweepSettings *ImageSweepSettings `json:"sweepSettings,omitempty"` + ValidationData *MLTableJobInput `json:"validationData,omitempty"` + ValidationDataSize *float64 `json:"validationDataSize,omitempty"` + + // Fields inherited from AutoMLVertical + + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` +} + +func (s ImageObjectDetection) AutoMLVertical() BaseAutoMLVerticalImpl { + return BaseAutoMLVerticalImpl{ + LogVerbosity: s.LogVerbosity, + TargetColumnName: s.TargetColumnName, + TaskType: s.TaskType, + TrainingData: s.TrainingData, + } +} + +var _ json.Marshaler = ImageObjectDetection{} + +func (s ImageObjectDetection) MarshalJSON() ([]byte, error) { + type wrapper ImageObjectDetection + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ImageObjectDetection: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ImageObjectDetection: %+v", err) + } + + decoded["taskType"] = "ImageObjectDetection" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ImageObjectDetection: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_imagesweepsettings.go b/resource-manager/machinelearningservices/2025-04-01/job/model_imagesweepsettings.go new file mode 100644 index 00000000000..3699015206d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_imagesweepsettings.go @@ -0,0 +1,42 @@ +package job + +import ( + "encoding/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 ImageSweepSettings struct { + EarlyTermination EarlyTerminationPolicy `json:"earlyTermination"` + SamplingAlgorithm SamplingAlgorithmType `json:"samplingAlgorithm"` +} + +var _ json.Unmarshaler = &ImageSweepSettings{} + +func (s *ImageSweepSettings) UnmarshalJSON(bytes []byte) error { + var decoded struct { + SamplingAlgorithm SamplingAlgorithmType `json:"samplingAlgorithm"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.SamplingAlgorithm = decoded.SamplingAlgorithm + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ImageSweepSettings into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["earlyTermination"]; ok { + impl, err := UnmarshalEarlyTerminationPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'EarlyTermination' for 'ImageSweepSettings': %+v", err) + } + s.EarlyTermination = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_jobbase.go b/resource-manager/machinelearningservices/2025-04-01/job/model_jobbase.go new file mode 100644 index 00000000000..ff361ea84ae --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_jobbase.go @@ -0,0 +1,169 @@ +package job + +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 JobBase interface { + JobBase() BaseJobBaseImpl +} + +var _ JobBase = BaseJobBaseImpl{} + +type BaseJobBaseImpl struct { + ComponentId *string `json:"componentId,omitempty"` + ComputeId *string `json:"computeId,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExperimentName *string `json:"experimentName,omitempty"` + Identity IdentityConfiguration `json:"identity"` + IsArchived *bool `json:"isArchived,omitempty"` + JobType JobType `json:"jobType"` + NotificationSetting *NotificationSetting `json:"notificationSetting,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Services *map[string]JobService `json:"services,omitempty"` + Status *JobStatus `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +func (s BaseJobBaseImpl) JobBase() BaseJobBaseImpl { + return s +} + +var _ JobBase = RawJobBaseImpl{} + +// RawJobBaseImpl 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 RawJobBaseImpl struct { + jobBase BaseJobBaseImpl + Type string + Values map[string]interface{} +} + +func (s RawJobBaseImpl) JobBase() BaseJobBaseImpl { + return s.jobBase +} + +var _ json.Unmarshaler = &BaseJobBaseImpl{} + +func (s *BaseJobBaseImpl) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ComponentId *string `json:"componentId,omitempty"` + ComputeId *string `json:"computeId,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExperimentName *string `json:"experimentName,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + JobType JobType `json:"jobType"` + NotificationSetting *NotificationSetting `json:"notificationSetting,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Services *map[string]JobService `json:"services,omitempty"` + Status *JobStatus `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ComponentId = decoded.ComponentId + s.ComputeId = decoded.ComputeId + s.Description = decoded.Description + s.DisplayName = decoded.DisplayName + s.ExperimentName = decoded.ExperimentName + s.IsArchived = decoded.IsArchived + s.JobType = decoded.JobType + s.NotificationSetting = decoded.NotificationSetting + s.Properties = decoded.Properties + s.Services = decoded.Services + s.Status = decoded.Status + s.Tags = decoded.Tags + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling BaseJobBaseImpl into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["identity"]; ok { + impl, err := UnmarshalIdentityConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Identity' for 'BaseJobBaseImpl': %+v", err) + } + s.Identity = impl + } + + return nil +} + +func UnmarshalJobBaseImplementation(input []byte) (JobBase, 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 JobBase into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["jobType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AutoML") { + var out AutoMLJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AutoMLJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Command") { + var out CommandJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CommandJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Pipeline") { + var out PipelineJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into PipelineJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Spark") { + var out SparkJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SparkJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Sweep") { + var out SweepJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SweepJob: %+v", err) + } + return out, nil + } + + var parent BaseJobBaseImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseJobBaseImpl: %+v", err) + } + + return RawJobBaseImpl{ + jobBase: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_jobbaseresource.go b/resource-manager/machinelearningservices/2025-04-01/job/model_jobbaseresource.go new file mode 100644 index 00000000000..28df474aa9d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_jobbaseresource.go @@ -0,0 +1,53 @@ +package job + +import ( + "encoding/json" + "fmt" + + "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 JobBaseResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties JobBase `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &JobBaseResource{} + +func (s *JobBaseResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Id = decoded.Id + s.Name = decoded.Name + s.SystemData = decoded.SystemData + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling JobBaseResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalJobBaseImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'JobBaseResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_jobinput.go b/resource-manager/machinelearningservices/2025-04-01/job/model_jobinput.go new file mode 100644 index 00000000000..ac124c0e497 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_jobinput.go @@ -0,0 +1,124 @@ +package job + +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 JobInput interface { + JobInput() BaseJobInputImpl +} + +var _ JobInput = BaseJobInputImpl{} + +type BaseJobInputImpl struct { + Description *string `json:"description,omitempty"` + JobInputType JobInputType `json:"jobInputType"` +} + +func (s BaseJobInputImpl) JobInput() BaseJobInputImpl { + return s +} + +var _ JobInput = RawJobInputImpl{} + +// RawJobInputImpl 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 RawJobInputImpl struct { + jobInput BaseJobInputImpl + Type string + Values map[string]interface{} +} + +func (s RawJobInputImpl) JobInput() BaseJobInputImpl { + return s.jobInput +} + +func UnmarshalJobInputImplementation(input []byte) (JobInput, 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 JobInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["jobInputType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "custom_model") { + var out CustomModelJobInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CustomModelJobInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "literal") { + var out LiteralJobInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into LiteralJobInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "mlflow_model") { + var out MLFlowModelJobInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MLFlowModelJobInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "mltable") { + var out MLTableJobInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MLTableJobInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "triton_model") { + var out TritonModelJobInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into TritonModelJobInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "uri_file") { + var out UriFileJobInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into UriFileJobInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "uri_folder") { + var out UriFolderJobInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into UriFolderJobInput: %+v", err) + } + return out, nil + } + + var parent BaseJobInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseJobInputImpl: %+v", err) + } + + return RawJobInputImpl{ + jobInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_joblimits.go b/resource-manager/machinelearningservices/2025-04-01/job/model_joblimits.go new file mode 100644 index 00000000000..9ff088d4a34 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_joblimits.go @@ -0,0 +1,84 @@ +package job + +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 JobLimits interface { + JobLimits() BaseJobLimitsImpl +} + +var _ JobLimits = BaseJobLimitsImpl{} + +type BaseJobLimitsImpl struct { + JobLimitsType JobLimitsType `json:"jobLimitsType"` + Timeout *string `json:"timeout,omitempty"` +} + +func (s BaseJobLimitsImpl) JobLimits() BaseJobLimitsImpl { + return s +} + +var _ JobLimits = RawJobLimitsImpl{} + +// RawJobLimitsImpl 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 RawJobLimitsImpl struct { + jobLimits BaseJobLimitsImpl + Type string + Values map[string]interface{} +} + +func (s RawJobLimitsImpl) JobLimits() BaseJobLimitsImpl { + return s.jobLimits +} + +func UnmarshalJobLimitsImplementation(input []byte) (JobLimits, 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 JobLimits into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["jobLimitsType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Command") { + var out CommandJobLimits + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CommandJobLimits: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Sweep") { + var out SweepJobLimits + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SweepJobLimits: %+v", err) + } + return out, nil + } + + var parent BaseJobLimitsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseJobLimitsImpl: %+v", err) + } + + return RawJobLimitsImpl{ + jobLimits: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_joboutput.go b/resource-manager/machinelearningservices/2025-04-01/job/model_joboutput.go new file mode 100644 index 00000000000..07e234c9064 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_joboutput.go @@ -0,0 +1,116 @@ +package job + +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 JobOutput interface { + JobOutput() BaseJobOutputImpl +} + +var _ JobOutput = BaseJobOutputImpl{} + +type BaseJobOutputImpl struct { + Description *string `json:"description,omitempty"` + JobOutputType JobOutputType `json:"jobOutputType"` +} + +func (s BaseJobOutputImpl) JobOutput() BaseJobOutputImpl { + return s +} + +var _ JobOutput = RawJobOutputImpl{} + +// RawJobOutputImpl 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 RawJobOutputImpl struct { + jobOutput BaseJobOutputImpl + Type string + Values map[string]interface{} +} + +func (s RawJobOutputImpl) JobOutput() BaseJobOutputImpl { + return s.jobOutput +} + +func UnmarshalJobOutputImplementation(input []byte) (JobOutput, 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 JobOutput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["jobOutputType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "custom_model") { + var out CustomModelJobOutput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CustomModelJobOutput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "mlflow_model") { + var out MLFlowModelJobOutput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MLFlowModelJobOutput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "mltable") { + var out MLTableJobOutput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MLTableJobOutput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "triton_model") { + var out TritonModelJobOutput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into TritonModelJobOutput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "uri_file") { + var out UriFileJobOutput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into UriFileJobOutput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "uri_folder") { + var out UriFolderJobOutput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into UriFolderJobOutput: %+v", err) + } + return out, nil + } + + var parent BaseJobOutputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseJobOutputImpl: %+v", err) + } + + return RawJobOutputImpl{ + jobOutput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_jobresourceconfiguration.go b/resource-manager/machinelearningservices/2025-04-01/job/model_jobresourceconfiguration.go new file mode 100644 index 00000000000..5aff309a114 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_jobresourceconfiguration.go @@ -0,0 +1,12 @@ +package job + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobResourceConfiguration struct { + DockerArgs *string `json:"dockerArgs,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceType *string `json:"instanceType,omitempty"` + Properties *map[string]interface{} `json:"properties,omitempty"` + ShmSize *string `json:"shmSize,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_jobservice.go b/resource-manager/machinelearningservices/2025-04-01/job/model_jobservice.go new file mode 100644 index 00000000000..e42b4b77612 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_jobservice.go @@ -0,0 +1,57 @@ +package job + +import ( + "encoding/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 JobService struct { + Endpoint *string `json:"endpoint,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + JobServiceType *string `json:"jobServiceType,omitempty"` + Nodes Nodes `json:"nodes"` + Port *int64 `json:"port,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Status *string `json:"status,omitempty"` +} + +var _ json.Unmarshaler = &JobService{} + +func (s *JobService) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Endpoint *string `json:"endpoint,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + JobServiceType *string `json:"jobServiceType,omitempty"` + Port *int64 `json:"port,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Status *string `json:"status,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Endpoint = decoded.Endpoint + s.ErrorMessage = decoded.ErrorMessage + s.JobServiceType = decoded.JobServiceType + s.Port = decoded.Port + s.Properties = decoded.Properties + s.Status = decoded.Status + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling JobService into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["nodes"]; ok { + impl, err := UnmarshalNodesImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Nodes' for 'JobService': %+v", err) + } + s.Nodes = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_literaljobinput.go b/resource-manager/machinelearningservices/2025-04-01/job/model_literaljobinput.go new file mode 100644 index 00000000000..b5c2d162c3b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_literaljobinput.go @@ -0,0 +1,52 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobInput = LiteralJobInput{} + +type LiteralJobInput struct { + Value string `json:"value"` + + // Fields inherited from JobInput + + Description *string `json:"description,omitempty"` + JobInputType JobInputType `json:"jobInputType"` +} + +func (s LiteralJobInput) JobInput() BaseJobInputImpl { + return BaseJobInputImpl{ + Description: s.Description, + JobInputType: s.JobInputType, + } +} + +var _ json.Marshaler = LiteralJobInput{} + +func (s LiteralJobInput) MarshalJSON() ([]byte, error) { + type wrapper LiteralJobInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling LiteralJobInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling LiteralJobInput: %+v", err) + } + + decoded["jobInputType"] = "literal" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling LiteralJobInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_managedidentity.go b/resource-manager/machinelearningservices/2025-04-01/job/model_managedidentity.go new file mode 100644 index 00000000000..650f80d2fe9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_managedidentity.go @@ -0,0 +1,52 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ IdentityConfiguration = ManagedIdentity{} + +type ManagedIdentity struct { + ClientId *string `json:"clientId,omitempty"` + ObjectId *string `json:"objectId,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + + // Fields inherited from IdentityConfiguration + + IdentityType IdentityConfigurationType `json:"identityType"` +} + +func (s ManagedIdentity) IdentityConfiguration() BaseIdentityConfigurationImpl { + return BaseIdentityConfigurationImpl{ + IdentityType: s.IdentityType, + } +} + +var _ json.Marshaler = ManagedIdentity{} + +func (s ManagedIdentity) MarshalJSON() ([]byte, error) { + type wrapper ManagedIdentity + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ManagedIdentity: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ManagedIdentity: %+v", err) + } + + decoded["identityType"] = "Managed" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ManagedIdentity: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_medianstoppingpolicy.go b/resource-manager/machinelearningservices/2025-04-01/job/model_medianstoppingpolicy.go new file mode 100644 index 00000000000..23def5e3925 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_medianstoppingpolicy.go @@ -0,0 +1,53 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EarlyTerminationPolicy = MedianStoppingPolicy{} + +type MedianStoppingPolicy struct { + + // Fields inherited from EarlyTerminationPolicy + + DelayEvaluation *int64 `json:"delayEvaluation,omitempty"` + EvaluationInterval *int64 `json:"evaluationInterval,omitempty"` + PolicyType EarlyTerminationPolicyType `json:"policyType"` +} + +func (s MedianStoppingPolicy) EarlyTerminationPolicy() BaseEarlyTerminationPolicyImpl { + return BaseEarlyTerminationPolicyImpl{ + DelayEvaluation: s.DelayEvaluation, + EvaluationInterval: s.EvaluationInterval, + PolicyType: s.PolicyType, + } +} + +var _ json.Marshaler = MedianStoppingPolicy{} + +func (s MedianStoppingPolicy) MarshalJSON() ([]byte, error) { + type wrapper MedianStoppingPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MedianStoppingPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MedianStoppingPolicy: %+v", err) + } + + decoded["policyType"] = "MedianStopping" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MedianStoppingPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_mlflowmodeljobinput.go b/resource-manager/machinelearningservices/2025-04-01/job/model_mlflowmodeljobinput.go new file mode 100644 index 00000000000..f4e7ba81f7b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_mlflowmodeljobinput.go @@ -0,0 +1,53 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobInput = MLFlowModelJobInput{} + +type MLFlowModelJobInput struct { + Mode *InputDeliveryMode `json:"mode,omitempty"` + Uri string `json:"uri"` + + // Fields inherited from JobInput + + Description *string `json:"description,omitempty"` + JobInputType JobInputType `json:"jobInputType"` +} + +func (s MLFlowModelJobInput) JobInput() BaseJobInputImpl { + return BaseJobInputImpl{ + Description: s.Description, + JobInputType: s.JobInputType, + } +} + +var _ json.Marshaler = MLFlowModelJobInput{} + +func (s MLFlowModelJobInput) MarshalJSON() ([]byte, error) { + type wrapper MLFlowModelJobInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MLFlowModelJobInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MLFlowModelJobInput: %+v", err) + } + + decoded["jobInputType"] = "mlflow_model" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MLFlowModelJobInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_mlflowmodeljoboutput.go b/resource-manager/machinelearningservices/2025-04-01/job/model_mlflowmodeljoboutput.go new file mode 100644 index 00000000000..d4be436b031 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_mlflowmodeljoboutput.go @@ -0,0 +1,53 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobOutput = MLFlowModelJobOutput{} + +type MLFlowModelJobOutput struct { + Mode *OutputDeliveryMode `json:"mode,omitempty"` + Uri *string `json:"uri,omitempty"` + + // Fields inherited from JobOutput + + Description *string `json:"description,omitempty"` + JobOutputType JobOutputType `json:"jobOutputType"` +} + +func (s MLFlowModelJobOutput) JobOutput() BaseJobOutputImpl { + return BaseJobOutputImpl{ + Description: s.Description, + JobOutputType: s.JobOutputType, + } +} + +var _ json.Marshaler = MLFlowModelJobOutput{} + +func (s MLFlowModelJobOutput) MarshalJSON() ([]byte, error) { + type wrapper MLFlowModelJobOutput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MLFlowModelJobOutput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MLFlowModelJobOutput: %+v", err) + } + + decoded["jobOutputType"] = "mlflow_model" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MLFlowModelJobOutput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_mltablejobinput.go b/resource-manager/machinelearningservices/2025-04-01/job/model_mltablejobinput.go new file mode 100644 index 00000000000..e39b578b529 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_mltablejobinput.go @@ -0,0 +1,53 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobInput = MLTableJobInput{} + +type MLTableJobInput struct { + Mode *InputDeliveryMode `json:"mode,omitempty"` + Uri string `json:"uri"` + + // Fields inherited from JobInput + + Description *string `json:"description,omitempty"` + JobInputType JobInputType `json:"jobInputType"` +} + +func (s MLTableJobInput) JobInput() BaseJobInputImpl { + return BaseJobInputImpl{ + Description: s.Description, + JobInputType: s.JobInputType, + } +} + +var _ json.Marshaler = MLTableJobInput{} + +func (s MLTableJobInput) MarshalJSON() ([]byte, error) { + type wrapper MLTableJobInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MLTableJobInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MLTableJobInput: %+v", err) + } + + decoded["jobInputType"] = "mltable" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MLTableJobInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_mltablejoboutput.go b/resource-manager/machinelearningservices/2025-04-01/job/model_mltablejoboutput.go new file mode 100644 index 00000000000..470fb02d0c2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_mltablejoboutput.go @@ -0,0 +1,53 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobOutput = MLTableJobOutput{} + +type MLTableJobOutput struct { + Mode *OutputDeliveryMode `json:"mode,omitempty"` + Uri *string `json:"uri,omitempty"` + + // Fields inherited from JobOutput + + Description *string `json:"description,omitempty"` + JobOutputType JobOutputType `json:"jobOutputType"` +} + +func (s MLTableJobOutput) JobOutput() BaseJobOutputImpl { + return BaseJobOutputImpl{ + Description: s.Description, + JobOutputType: s.JobOutputType, + } +} + +var _ json.Marshaler = MLTableJobOutput{} + +func (s MLTableJobOutput) MarshalJSON() ([]byte, error) { + type wrapper MLTableJobOutput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MLTableJobOutput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MLTableJobOutput: %+v", err) + } + + decoded["jobOutputType"] = "mltable" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MLTableJobOutput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_mpi.go b/resource-manager/machinelearningservices/2025-04-01/job/model_mpi.go new file mode 100644 index 00000000000..9eeed1b786f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_mpi.go @@ -0,0 +1,50 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DistributionConfiguration = Mpi{} + +type Mpi struct { + ProcessCountPerInstance *int64 `json:"processCountPerInstance,omitempty"` + + // Fields inherited from DistributionConfiguration + + DistributionType DistributionType `json:"distributionType"` +} + +func (s Mpi) DistributionConfiguration() BaseDistributionConfigurationImpl { + return BaseDistributionConfigurationImpl{ + DistributionType: s.DistributionType, + } +} + +var _ json.Marshaler = Mpi{} + +func (s Mpi) MarshalJSON() ([]byte, error) { + type wrapper Mpi + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling Mpi: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling Mpi: %+v", err) + } + + decoded["distributionType"] = "Mpi" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling Mpi: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_ncrossvalidations.go b/resource-manager/machinelearningservices/2025-04-01/job/model_ncrossvalidations.go new file mode 100644 index 00000000000..e4cc7f537f0 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_ncrossvalidations.go @@ -0,0 +1,83 @@ +package job + +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 NCrossValidations interface { + NCrossValidations() BaseNCrossValidationsImpl +} + +var _ NCrossValidations = BaseNCrossValidationsImpl{} + +type BaseNCrossValidationsImpl struct { + Mode NCrossValidationsMode `json:"mode"` +} + +func (s BaseNCrossValidationsImpl) NCrossValidations() BaseNCrossValidationsImpl { + return s +} + +var _ NCrossValidations = RawNCrossValidationsImpl{} + +// RawNCrossValidationsImpl 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 RawNCrossValidationsImpl struct { + nCrossValidations BaseNCrossValidationsImpl + Type string + Values map[string]interface{} +} + +func (s RawNCrossValidationsImpl) NCrossValidations() BaseNCrossValidationsImpl { + return s.nCrossValidations +} + +func UnmarshalNCrossValidationsImplementation(input []byte) (NCrossValidations, 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 NCrossValidations into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["mode"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Auto") { + var out AutoNCrossValidations + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AutoNCrossValidations: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Custom") { + var out CustomNCrossValidations + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CustomNCrossValidations: %+v", err) + } + return out, nil + } + + var parent BaseNCrossValidationsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseNCrossValidationsImpl: %+v", err) + } + + return RawNCrossValidationsImpl{ + nCrossValidations: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_nlpverticallimitsettings.go b/resource-manager/machinelearningservices/2025-04-01/job/model_nlpverticallimitsettings.go new file mode 100644 index 00000000000..f13cc7bee0d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_nlpverticallimitsettings.go @@ -0,0 +1,10 @@ +package job + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NlpVerticalLimitSettings struct { + MaxConcurrentTrials *int64 `json:"maxConcurrentTrials,omitempty"` + MaxTrials *int64 `json:"maxTrials,omitempty"` + Timeout *string `json:"timeout,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_nodes.go b/resource-manager/machinelearningservices/2025-04-01/job/model_nodes.go new file mode 100644 index 00000000000..c0857a5f401 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_nodes.go @@ -0,0 +1,75 @@ +package job + +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 Nodes interface { + Nodes() BaseNodesImpl +} + +var _ Nodes = BaseNodesImpl{} + +type BaseNodesImpl struct { + NodesValueType NodesValueType `json:"nodesValueType"` +} + +func (s BaseNodesImpl) Nodes() BaseNodesImpl { + return s +} + +var _ Nodes = RawNodesImpl{} + +// RawNodesImpl 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 RawNodesImpl struct { + nodes BaseNodesImpl + Type string + Values map[string]interface{} +} + +func (s RawNodesImpl) Nodes() BaseNodesImpl { + return s.nodes +} + +func UnmarshalNodesImplementation(input []byte) (Nodes, 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 Nodes into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["nodesValueType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "All") { + var out AllNodes + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AllNodes: %+v", err) + } + return out, nil + } + + var parent BaseNodesImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseNodesImpl: %+v", err) + } + + return RawNodesImpl{ + nodes: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_notificationsetting.go b/resource-manager/machinelearningservices/2025-04-01/job/model_notificationsetting.go new file mode 100644 index 00000000000..0517657245d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_notificationsetting.go @@ -0,0 +1,54 @@ +package job + +import ( + "encoding/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 NotificationSetting struct { + EmailOn *[]EmailNotificationEnableType `json:"emailOn,omitempty"` + Emails *[]string `json:"emails,omitempty"` + WebHooks *map[string]Webhook `json:"webhooks,omitempty"` +} + +var _ json.Unmarshaler = &NotificationSetting{} + +func (s *NotificationSetting) UnmarshalJSON(bytes []byte) error { + var decoded struct { + EmailOn *[]EmailNotificationEnableType `json:"emailOn,omitempty"` + Emails *[]string `json:"emails,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.EmailOn = decoded.EmailOn + s.Emails = decoded.Emails + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling NotificationSetting into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["webhooks"]; ok { + var dictionaryTemp map[string]json.RawMessage + if err := json.Unmarshal(v, &dictionaryTemp); err != nil { + return fmt.Errorf("unmarshaling WebHooks into dictionary map[string]json.RawMessage: %+v", err) + } + + output := make(map[string]Webhook) + for key, val := range dictionaryTemp { + impl, err := UnmarshalWebhookImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling key %q field 'WebHooks' for 'NotificationSetting': %+v", key, err) + } + output[key] = impl + } + s.WebHooks = &output + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_objective.go b/resource-manager/machinelearningservices/2025-04-01/job/model_objective.go new file mode 100644 index 00000000000..e7e9f85700b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_objective.go @@ -0,0 +1,9 @@ +package job + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Objective struct { + Goal Goal `json:"goal"` + PrimaryMetric string `json:"primaryMetric"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_pipelinejob.go b/resource-manager/machinelearningservices/2025-04-01/job/model_pipelinejob.go new file mode 100644 index 00000000000..afea6f11342 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_pipelinejob.go @@ -0,0 +1,168 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobBase = PipelineJob{} + +type PipelineJob struct { + Inputs *map[string]JobInput `json:"inputs,omitempty"` + Jobs *map[string]interface{} `json:"jobs,omitempty"` + Outputs *map[string]JobOutput `json:"outputs,omitempty"` + Settings *interface{} `json:"settings,omitempty"` + SourceJobId *string `json:"sourceJobId,omitempty"` + + // Fields inherited from JobBase + + ComponentId *string `json:"componentId,omitempty"` + ComputeId *string `json:"computeId,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExperimentName *string `json:"experimentName,omitempty"` + Identity IdentityConfiguration `json:"identity"` + IsArchived *bool `json:"isArchived,omitempty"` + JobType JobType `json:"jobType"` + NotificationSetting *NotificationSetting `json:"notificationSetting,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Services *map[string]JobService `json:"services,omitempty"` + Status *JobStatus `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +func (s PipelineJob) JobBase() BaseJobBaseImpl { + return BaseJobBaseImpl{ + ComponentId: s.ComponentId, + ComputeId: s.ComputeId, + Description: s.Description, + DisplayName: s.DisplayName, + ExperimentName: s.ExperimentName, + Identity: s.Identity, + IsArchived: s.IsArchived, + JobType: s.JobType, + NotificationSetting: s.NotificationSetting, + Properties: s.Properties, + Services: s.Services, + Status: s.Status, + Tags: s.Tags, + } +} + +var _ json.Marshaler = PipelineJob{} + +func (s PipelineJob) MarshalJSON() ([]byte, error) { + type wrapper PipelineJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling PipelineJob: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling PipelineJob: %+v", err) + } + + decoded["jobType"] = "Pipeline" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling PipelineJob: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &PipelineJob{} + +func (s *PipelineJob) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Jobs *map[string]interface{} `json:"jobs,omitempty"` + Settings *interface{} `json:"settings,omitempty"` + SourceJobId *string `json:"sourceJobId,omitempty"` + ComponentId *string `json:"componentId,omitempty"` + ComputeId *string `json:"computeId,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExperimentName *string `json:"experimentName,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + JobType JobType `json:"jobType"` + NotificationSetting *NotificationSetting `json:"notificationSetting,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Services *map[string]JobService `json:"services,omitempty"` + Status *JobStatus `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Jobs = decoded.Jobs + s.Settings = decoded.Settings + s.SourceJobId = decoded.SourceJobId + s.ComponentId = decoded.ComponentId + s.ComputeId = decoded.ComputeId + s.Description = decoded.Description + s.DisplayName = decoded.DisplayName + s.ExperimentName = decoded.ExperimentName + s.IsArchived = decoded.IsArchived + s.JobType = decoded.JobType + s.NotificationSetting = decoded.NotificationSetting + s.Properties = decoded.Properties + s.Services = decoded.Services + s.Status = decoded.Status + s.Tags = decoded.Tags + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling PipelineJob into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["identity"]; ok { + impl, err := UnmarshalIdentityConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Identity' for 'PipelineJob': %+v", err) + } + s.Identity = impl + } + + if v, ok := temp["inputs"]; ok { + var dictionaryTemp map[string]json.RawMessage + if err := json.Unmarshal(v, &dictionaryTemp); err != nil { + return fmt.Errorf("unmarshaling Inputs into dictionary map[string]json.RawMessage: %+v", err) + } + + output := make(map[string]JobInput) + for key, val := range dictionaryTemp { + impl, err := UnmarshalJobInputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling key %q field 'Inputs' for 'PipelineJob': %+v", key, err) + } + output[key] = impl + } + s.Inputs = &output + } + + if v, ok := temp["outputs"]; ok { + var dictionaryTemp map[string]json.RawMessage + if err := json.Unmarshal(v, &dictionaryTemp); err != nil { + return fmt.Errorf("unmarshaling Outputs into dictionary map[string]json.RawMessage: %+v", err) + } + + output := make(map[string]JobOutput) + for key, val := range dictionaryTemp { + impl, err := UnmarshalJobOutputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling key %q field 'Outputs' for 'PipelineJob': %+v", key, err) + } + output[key] = impl + } + s.Outputs = &output + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_pytorch.go b/resource-manager/machinelearningservices/2025-04-01/job/model_pytorch.go new file mode 100644 index 00000000000..13ffe867753 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_pytorch.go @@ -0,0 +1,50 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DistributionConfiguration = PyTorch{} + +type PyTorch struct { + ProcessCountPerInstance *int64 `json:"processCountPerInstance,omitempty"` + + // Fields inherited from DistributionConfiguration + + DistributionType DistributionType `json:"distributionType"` +} + +func (s PyTorch) DistributionConfiguration() BaseDistributionConfigurationImpl { + return BaseDistributionConfigurationImpl{ + DistributionType: s.DistributionType, + } +} + +var _ json.Marshaler = PyTorch{} + +func (s PyTorch) MarshalJSON() ([]byte, error) { + type wrapper PyTorch + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling PyTorch: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling PyTorch: %+v", err) + } + + decoded["distributionType"] = "PyTorch" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling PyTorch: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_queuesettings.go b/resource-manager/machinelearningservices/2025-04-01/job/model_queuesettings.go new file mode 100644 index 00000000000..3209493c9b2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_queuesettings.go @@ -0,0 +1,8 @@ +package job + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueueSettings struct { + JobTier *JobTier `json:"jobTier,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_randomsamplingalgorithm.go b/resource-manager/machinelearningservices/2025-04-01/job/model_randomsamplingalgorithm.go new file mode 100644 index 00000000000..5057b869f15 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_randomsamplingalgorithm.go @@ -0,0 +1,51 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SamplingAlgorithm = RandomSamplingAlgorithm{} + +type RandomSamplingAlgorithm struct { + Rule *RandomSamplingAlgorithmRule `json:"rule,omitempty"` + Seed *int64 `json:"seed,omitempty"` + + // Fields inherited from SamplingAlgorithm + + SamplingAlgorithmType SamplingAlgorithmType `json:"samplingAlgorithmType"` +} + +func (s RandomSamplingAlgorithm) SamplingAlgorithm() BaseSamplingAlgorithmImpl { + return BaseSamplingAlgorithmImpl{ + SamplingAlgorithmType: s.SamplingAlgorithmType, + } +} + +var _ json.Marshaler = RandomSamplingAlgorithm{} + +func (s RandomSamplingAlgorithm) MarshalJSON() ([]byte, error) { + type wrapper RandomSamplingAlgorithm + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RandomSamplingAlgorithm: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RandomSamplingAlgorithm: %+v", err) + } + + decoded["samplingAlgorithmType"] = "Random" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RandomSamplingAlgorithm: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_regression.go b/resource-manager/machinelearningservices/2025-04-01/job/model_regression.go new file mode 100644 index 00000000000..4e5f81877dd --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_regression.go @@ -0,0 +1,120 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AutoMLVertical = Regression{} + +type Regression struct { + CvSplitColumnNames *[]string `json:"cvSplitColumnNames,omitempty"` + FeaturizationSettings *TableVerticalFeaturizationSettings `json:"featurizationSettings,omitempty"` + LimitSettings *TableVerticalLimitSettings `json:"limitSettings,omitempty"` + NCrossValidations NCrossValidations `json:"nCrossValidations"` + PrimaryMetric *RegressionPrimaryMetrics `json:"primaryMetric,omitempty"` + TestData *MLTableJobInput `json:"testData,omitempty"` + TestDataSize *float64 `json:"testDataSize,omitempty"` + TrainingSettings *RegressionTrainingSettings `json:"trainingSettings,omitempty"` + ValidationData *MLTableJobInput `json:"validationData,omitempty"` + ValidationDataSize *float64 `json:"validationDataSize,omitempty"` + WeightColumnName *string `json:"weightColumnName,omitempty"` + + // Fields inherited from AutoMLVertical + + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` +} + +func (s Regression) AutoMLVertical() BaseAutoMLVerticalImpl { + return BaseAutoMLVerticalImpl{ + LogVerbosity: s.LogVerbosity, + TargetColumnName: s.TargetColumnName, + TaskType: s.TaskType, + TrainingData: s.TrainingData, + } +} + +var _ json.Marshaler = Regression{} + +func (s Regression) MarshalJSON() ([]byte, error) { + type wrapper Regression + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling Regression: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling Regression: %+v", err) + } + + decoded["taskType"] = "Regression" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling Regression: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &Regression{} + +func (s *Regression) UnmarshalJSON(bytes []byte) error { + var decoded struct { + CvSplitColumnNames *[]string `json:"cvSplitColumnNames,omitempty"` + FeaturizationSettings *TableVerticalFeaturizationSettings `json:"featurizationSettings,omitempty"` + LimitSettings *TableVerticalLimitSettings `json:"limitSettings,omitempty"` + PrimaryMetric *RegressionPrimaryMetrics `json:"primaryMetric,omitempty"` + TestData *MLTableJobInput `json:"testData,omitempty"` + TestDataSize *float64 `json:"testDataSize,omitempty"` + TrainingSettings *RegressionTrainingSettings `json:"trainingSettings,omitempty"` + ValidationData *MLTableJobInput `json:"validationData,omitempty"` + ValidationDataSize *float64 `json:"validationDataSize,omitempty"` + WeightColumnName *string `json:"weightColumnName,omitempty"` + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.CvSplitColumnNames = decoded.CvSplitColumnNames + s.FeaturizationSettings = decoded.FeaturizationSettings + s.LimitSettings = decoded.LimitSettings + s.PrimaryMetric = decoded.PrimaryMetric + s.TestData = decoded.TestData + s.TestDataSize = decoded.TestDataSize + s.TrainingSettings = decoded.TrainingSettings + s.ValidationData = decoded.ValidationData + s.ValidationDataSize = decoded.ValidationDataSize + s.WeightColumnName = decoded.WeightColumnName + s.LogVerbosity = decoded.LogVerbosity + s.TargetColumnName = decoded.TargetColumnName + s.TaskType = decoded.TaskType + s.TrainingData = decoded.TrainingData + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling Regression into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["nCrossValidations"]; ok { + impl, err := UnmarshalNCrossValidationsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'NCrossValidations' for 'Regression': %+v", err) + } + s.NCrossValidations = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_regressiontrainingsettings.go b/resource-manager/machinelearningservices/2025-04-01/job/model_regressiontrainingsettings.go new file mode 100644 index 00000000000..59b8bf9aa44 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_regressiontrainingsettings.go @@ -0,0 +1,16 @@ +package job + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegressionTrainingSettings struct { + AllowedTrainingAlgorithms *[]RegressionModels `json:"allowedTrainingAlgorithms,omitempty"` + BlockedTrainingAlgorithms *[]RegressionModels `json:"blockedTrainingAlgorithms,omitempty"` + EnableDnnTraining *bool `json:"enableDnnTraining,omitempty"` + EnableModelExplainability *bool `json:"enableModelExplainability,omitempty"` + EnableOnnxCompatibleModels *bool `json:"enableOnnxCompatibleModels,omitempty"` + EnableStackEnsemble *bool `json:"enableStackEnsemble,omitempty"` + EnableVoteEnsemble *bool `json:"enableVoteEnsemble,omitempty"` + EnsembleModelDownloadTimeout *string `json:"ensembleModelDownloadTimeout,omitempty"` + StackEnsembleSettings *StackEnsembleSettings `json:"stackEnsembleSettings,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_samplingalgorithm.go b/resource-manager/machinelearningservices/2025-04-01/job/model_samplingalgorithm.go new file mode 100644 index 00000000000..a004aa1d0bf --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_samplingalgorithm.go @@ -0,0 +1,91 @@ +package job + +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 SamplingAlgorithm interface { + SamplingAlgorithm() BaseSamplingAlgorithmImpl +} + +var _ SamplingAlgorithm = BaseSamplingAlgorithmImpl{} + +type BaseSamplingAlgorithmImpl struct { + SamplingAlgorithmType SamplingAlgorithmType `json:"samplingAlgorithmType"` +} + +func (s BaseSamplingAlgorithmImpl) SamplingAlgorithm() BaseSamplingAlgorithmImpl { + return s +} + +var _ SamplingAlgorithm = RawSamplingAlgorithmImpl{} + +// RawSamplingAlgorithmImpl 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 RawSamplingAlgorithmImpl struct { + samplingAlgorithm BaseSamplingAlgorithmImpl + Type string + Values map[string]interface{} +} + +func (s RawSamplingAlgorithmImpl) SamplingAlgorithm() BaseSamplingAlgorithmImpl { + return s.samplingAlgorithm +} + +func UnmarshalSamplingAlgorithmImplementation(input []byte) (SamplingAlgorithm, 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 SamplingAlgorithm into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["samplingAlgorithmType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Bayesian") { + var out BayesianSamplingAlgorithm + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into BayesianSamplingAlgorithm: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Grid") { + var out GridSamplingAlgorithm + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GridSamplingAlgorithm: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Random") { + var out RandomSamplingAlgorithm + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RandomSamplingAlgorithm: %+v", err) + } + return out, nil + } + + var parent BaseSamplingAlgorithmImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseSamplingAlgorithmImpl: %+v", err) + } + + return RawSamplingAlgorithmImpl{ + samplingAlgorithm: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_seasonality.go b/resource-manager/machinelearningservices/2025-04-01/job/model_seasonality.go new file mode 100644 index 00000000000..ac55b9a37db --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_seasonality.go @@ -0,0 +1,83 @@ +package job + +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 Seasonality interface { + Seasonality() BaseSeasonalityImpl +} + +var _ Seasonality = BaseSeasonalityImpl{} + +type BaseSeasonalityImpl struct { + Mode SeasonalityMode `json:"mode"` +} + +func (s BaseSeasonalityImpl) Seasonality() BaseSeasonalityImpl { + return s +} + +var _ Seasonality = RawSeasonalityImpl{} + +// RawSeasonalityImpl 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 RawSeasonalityImpl struct { + seasonality BaseSeasonalityImpl + Type string + Values map[string]interface{} +} + +func (s RawSeasonalityImpl) Seasonality() BaseSeasonalityImpl { + return s.seasonality +} + +func UnmarshalSeasonalityImplementation(input []byte) (Seasonality, 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 Seasonality into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["mode"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Auto") { + var out AutoSeasonality + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AutoSeasonality: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Custom") { + var out CustomSeasonality + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CustomSeasonality: %+v", err) + } + return out, nil + } + + var parent BaseSeasonalityImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseSeasonalityImpl: %+v", err) + } + + return RawSeasonalityImpl{ + seasonality: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_sparkjob.go b/resource-manager/machinelearningservices/2025-04-01/job/model_sparkjob.go new file mode 100644 index 00000000000..5dc61ccd3f8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_sparkjob.go @@ -0,0 +1,201 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobBase = SparkJob{} + +type SparkJob struct { + Archives *[]string `json:"archives,omitempty"` + Args *string `json:"args,omitempty"` + CodeId string `json:"codeId"` + Conf *map[string]string `json:"conf,omitempty"` + Entry SparkJobEntry `json:"entry"` + EnvironmentId *string `json:"environmentId,omitempty"` + EnvironmentVariables *map[string]string `json:"environmentVariables,omitempty"` + Files *[]string `json:"files,omitempty"` + Inputs *map[string]JobInput `json:"inputs,omitempty"` + Jars *[]string `json:"jars,omitempty"` + Outputs *map[string]JobOutput `json:"outputs,omitempty"` + PyFiles *[]string `json:"pyFiles,omitempty"` + QueueSettings *QueueSettings `json:"queueSettings,omitempty"` + Resources *SparkResourceConfiguration `json:"resources,omitempty"` + + // Fields inherited from JobBase + + ComponentId *string `json:"componentId,omitempty"` + ComputeId *string `json:"computeId,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExperimentName *string `json:"experimentName,omitempty"` + Identity IdentityConfiguration `json:"identity"` + IsArchived *bool `json:"isArchived,omitempty"` + JobType JobType `json:"jobType"` + NotificationSetting *NotificationSetting `json:"notificationSetting,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Services *map[string]JobService `json:"services,omitempty"` + Status *JobStatus `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +func (s SparkJob) JobBase() BaseJobBaseImpl { + return BaseJobBaseImpl{ + ComponentId: s.ComponentId, + ComputeId: s.ComputeId, + Description: s.Description, + DisplayName: s.DisplayName, + ExperimentName: s.ExperimentName, + Identity: s.Identity, + IsArchived: s.IsArchived, + JobType: s.JobType, + NotificationSetting: s.NotificationSetting, + Properties: s.Properties, + Services: s.Services, + Status: s.Status, + Tags: s.Tags, + } +} + +var _ json.Marshaler = SparkJob{} + +func (s SparkJob) MarshalJSON() ([]byte, error) { + type wrapper SparkJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SparkJob: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SparkJob: %+v", err) + } + + decoded["jobType"] = "Spark" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SparkJob: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &SparkJob{} + +func (s *SparkJob) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Archives *[]string `json:"archives,omitempty"` + Args *string `json:"args,omitempty"` + CodeId string `json:"codeId"` + Conf *map[string]string `json:"conf,omitempty"` + EnvironmentId *string `json:"environmentId,omitempty"` + EnvironmentVariables *map[string]string `json:"environmentVariables,omitempty"` + Files *[]string `json:"files,omitempty"` + Jars *[]string `json:"jars,omitempty"` + PyFiles *[]string `json:"pyFiles,omitempty"` + QueueSettings *QueueSettings `json:"queueSettings,omitempty"` + Resources *SparkResourceConfiguration `json:"resources,omitempty"` + ComponentId *string `json:"componentId,omitempty"` + ComputeId *string `json:"computeId,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExperimentName *string `json:"experimentName,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + JobType JobType `json:"jobType"` + NotificationSetting *NotificationSetting `json:"notificationSetting,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Services *map[string]JobService `json:"services,omitempty"` + Status *JobStatus `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Archives = decoded.Archives + s.Args = decoded.Args + s.CodeId = decoded.CodeId + s.Conf = decoded.Conf + s.EnvironmentId = decoded.EnvironmentId + s.EnvironmentVariables = decoded.EnvironmentVariables + s.Files = decoded.Files + s.Jars = decoded.Jars + s.PyFiles = decoded.PyFiles + s.QueueSettings = decoded.QueueSettings + s.Resources = decoded.Resources + s.ComponentId = decoded.ComponentId + s.ComputeId = decoded.ComputeId + s.Description = decoded.Description + s.DisplayName = decoded.DisplayName + s.ExperimentName = decoded.ExperimentName + s.IsArchived = decoded.IsArchived + s.JobType = decoded.JobType + s.NotificationSetting = decoded.NotificationSetting + s.Properties = decoded.Properties + s.Services = decoded.Services + s.Status = decoded.Status + s.Tags = decoded.Tags + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling SparkJob into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["entry"]; ok { + impl, err := UnmarshalSparkJobEntryImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Entry' for 'SparkJob': %+v", err) + } + s.Entry = impl + } + + if v, ok := temp["identity"]; ok { + impl, err := UnmarshalIdentityConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Identity' for 'SparkJob': %+v", err) + } + s.Identity = impl + } + + if v, ok := temp["inputs"]; ok { + var dictionaryTemp map[string]json.RawMessage + if err := json.Unmarshal(v, &dictionaryTemp); err != nil { + return fmt.Errorf("unmarshaling Inputs into dictionary map[string]json.RawMessage: %+v", err) + } + + output := make(map[string]JobInput) + for key, val := range dictionaryTemp { + impl, err := UnmarshalJobInputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling key %q field 'Inputs' for 'SparkJob': %+v", key, err) + } + output[key] = impl + } + s.Inputs = &output + } + + if v, ok := temp["outputs"]; ok { + var dictionaryTemp map[string]json.RawMessage + if err := json.Unmarshal(v, &dictionaryTemp); err != nil { + return fmt.Errorf("unmarshaling Outputs into dictionary map[string]json.RawMessage: %+v", err) + } + + output := make(map[string]JobOutput) + for key, val := range dictionaryTemp { + impl, err := UnmarshalJobOutputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling key %q field 'Outputs' for 'SparkJob': %+v", key, err) + } + output[key] = impl + } + s.Outputs = &output + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_sparkjobentry.go b/resource-manager/machinelearningservices/2025-04-01/job/model_sparkjobentry.go new file mode 100644 index 00000000000..6d35781f2c1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_sparkjobentry.go @@ -0,0 +1,83 @@ +package job + +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 SparkJobEntry interface { + SparkJobEntry() BaseSparkJobEntryImpl +} + +var _ SparkJobEntry = BaseSparkJobEntryImpl{} + +type BaseSparkJobEntryImpl struct { + SparkJobEntryType SparkJobEntryType `json:"sparkJobEntryType"` +} + +func (s BaseSparkJobEntryImpl) SparkJobEntry() BaseSparkJobEntryImpl { + return s +} + +var _ SparkJobEntry = RawSparkJobEntryImpl{} + +// RawSparkJobEntryImpl 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 RawSparkJobEntryImpl struct { + sparkJobEntry BaseSparkJobEntryImpl + Type string + Values map[string]interface{} +} + +func (s RawSparkJobEntryImpl) SparkJobEntry() BaseSparkJobEntryImpl { + return s.sparkJobEntry +} + +func UnmarshalSparkJobEntryImplementation(input []byte) (SparkJobEntry, 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 SparkJobEntry into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["sparkJobEntryType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "SparkJobPythonEntry") { + var out SparkJobPythonEntry + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SparkJobPythonEntry: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SparkJobScalaEntry") { + var out SparkJobScalaEntry + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SparkJobScalaEntry: %+v", err) + } + return out, nil + } + + var parent BaseSparkJobEntryImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseSparkJobEntryImpl: %+v", err) + } + + return RawSparkJobEntryImpl{ + sparkJobEntry: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_sparkjobpythonentry.go b/resource-manager/machinelearningservices/2025-04-01/job/model_sparkjobpythonentry.go new file mode 100644 index 00000000000..c41bed897f1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_sparkjobpythonentry.go @@ -0,0 +1,50 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SparkJobEntry = SparkJobPythonEntry{} + +type SparkJobPythonEntry struct { + File string `json:"file"` + + // Fields inherited from SparkJobEntry + + SparkJobEntryType SparkJobEntryType `json:"sparkJobEntryType"` +} + +func (s SparkJobPythonEntry) SparkJobEntry() BaseSparkJobEntryImpl { + return BaseSparkJobEntryImpl{ + SparkJobEntryType: s.SparkJobEntryType, + } +} + +var _ json.Marshaler = SparkJobPythonEntry{} + +func (s SparkJobPythonEntry) MarshalJSON() ([]byte, error) { + type wrapper SparkJobPythonEntry + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SparkJobPythonEntry: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SparkJobPythonEntry: %+v", err) + } + + decoded["sparkJobEntryType"] = "SparkJobPythonEntry" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SparkJobPythonEntry: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_sparkjobscalaentry.go b/resource-manager/machinelearningservices/2025-04-01/job/model_sparkjobscalaentry.go new file mode 100644 index 00000000000..8afd4c0065c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_sparkjobscalaentry.go @@ -0,0 +1,50 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SparkJobEntry = SparkJobScalaEntry{} + +type SparkJobScalaEntry struct { + ClassName string `json:"className"` + + // Fields inherited from SparkJobEntry + + SparkJobEntryType SparkJobEntryType `json:"sparkJobEntryType"` +} + +func (s SparkJobScalaEntry) SparkJobEntry() BaseSparkJobEntryImpl { + return BaseSparkJobEntryImpl{ + SparkJobEntryType: s.SparkJobEntryType, + } +} + +var _ json.Marshaler = SparkJobScalaEntry{} + +func (s SparkJobScalaEntry) MarshalJSON() ([]byte, error) { + type wrapper SparkJobScalaEntry + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SparkJobScalaEntry: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SparkJobScalaEntry: %+v", err) + } + + decoded["sparkJobEntryType"] = "SparkJobScalaEntry" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SparkJobScalaEntry: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_sparkresourceconfiguration.go b/resource-manager/machinelearningservices/2025-04-01/job/model_sparkresourceconfiguration.go new file mode 100644 index 00000000000..e89638235be --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_sparkresourceconfiguration.go @@ -0,0 +1,9 @@ +package job + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SparkResourceConfiguration struct { + InstanceType *string `json:"instanceType,omitempty"` + RuntimeVersion *string `json:"runtimeVersion,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_stackensemblesettings.go b/resource-manager/machinelearningservices/2025-04-01/job/model_stackensemblesettings.go new file mode 100644 index 00000000000..70109312259 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_stackensemblesettings.go @@ -0,0 +1,10 @@ +package job + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StackEnsembleSettings struct { + StackMetaLearnerKWargs *interface{} `json:"stackMetaLearnerKWargs,omitempty"` + StackMetaLearnerTrainPercentage *float64 `json:"stackMetaLearnerTrainPercentage,omitempty"` + StackMetaLearnerType *StackMetaLearnerType `json:"stackMetaLearnerType,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_sweepjob.go b/resource-manager/machinelearningservices/2025-04-01/job/model_sweepjob.go new file mode 100644 index 00000000000..e569a671635 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_sweepjob.go @@ -0,0 +1,192 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobBase = SweepJob{} + +type SweepJob struct { + EarlyTermination EarlyTerminationPolicy `json:"earlyTermination"` + Inputs *map[string]JobInput `json:"inputs,omitempty"` + Limits *SweepJobLimits `json:"limits,omitempty"` + Objective Objective `json:"objective"` + Outputs *map[string]JobOutput `json:"outputs,omitempty"` + QueueSettings *QueueSettings `json:"queueSettings,omitempty"` + SamplingAlgorithm SamplingAlgorithm `json:"samplingAlgorithm"` + SearchSpace interface{} `json:"searchSpace"` + Trial TrialComponent `json:"trial"` + + // Fields inherited from JobBase + + ComponentId *string `json:"componentId,omitempty"` + ComputeId *string `json:"computeId,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExperimentName *string `json:"experimentName,omitempty"` + Identity IdentityConfiguration `json:"identity"` + IsArchived *bool `json:"isArchived,omitempty"` + JobType JobType `json:"jobType"` + NotificationSetting *NotificationSetting `json:"notificationSetting,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Services *map[string]JobService `json:"services,omitempty"` + Status *JobStatus `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +func (s SweepJob) JobBase() BaseJobBaseImpl { + return BaseJobBaseImpl{ + ComponentId: s.ComponentId, + ComputeId: s.ComputeId, + Description: s.Description, + DisplayName: s.DisplayName, + ExperimentName: s.ExperimentName, + Identity: s.Identity, + IsArchived: s.IsArchived, + JobType: s.JobType, + NotificationSetting: s.NotificationSetting, + Properties: s.Properties, + Services: s.Services, + Status: s.Status, + Tags: s.Tags, + } +} + +var _ json.Marshaler = SweepJob{} + +func (s SweepJob) MarshalJSON() ([]byte, error) { + type wrapper SweepJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SweepJob: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SweepJob: %+v", err) + } + + decoded["jobType"] = "Sweep" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SweepJob: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &SweepJob{} + +func (s *SweepJob) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Limits *SweepJobLimits `json:"limits,omitempty"` + Objective Objective `json:"objective"` + QueueSettings *QueueSettings `json:"queueSettings,omitempty"` + SearchSpace interface{} `json:"searchSpace"` + Trial TrialComponent `json:"trial"` + ComponentId *string `json:"componentId,omitempty"` + ComputeId *string `json:"computeId,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExperimentName *string `json:"experimentName,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + JobType JobType `json:"jobType"` + NotificationSetting *NotificationSetting `json:"notificationSetting,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Services *map[string]JobService `json:"services,omitempty"` + Status *JobStatus `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Limits = decoded.Limits + s.Objective = decoded.Objective + s.QueueSettings = decoded.QueueSettings + s.SearchSpace = decoded.SearchSpace + s.Trial = decoded.Trial + s.ComponentId = decoded.ComponentId + s.ComputeId = decoded.ComputeId + s.Description = decoded.Description + s.DisplayName = decoded.DisplayName + s.ExperimentName = decoded.ExperimentName + s.IsArchived = decoded.IsArchived + s.JobType = decoded.JobType + s.NotificationSetting = decoded.NotificationSetting + s.Properties = decoded.Properties + s.Services = decoded.Services + s.Status = decoded.Status + s.Tags = decoded.Tags + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling SweepJob into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["earlyTermination"]; ok { + impl, err := UnmarshalEarlyTerminationPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'EarlyTermination' for 'SweepJob': %+v", err) + } + s.EarlyTermination = impl + } + + if v, ok := temp["identity"]; ok { + impl, err := UnmarshalIdentityConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Identity' for 'SweepJob': %+v", err) + } + s.Identity = impl + } + + if v, ok := temp["inputs"]; ok { + var dictionaryTemp map[string]json.RawMessage + if err := json.Unmarshal(v, &dictionaryTemp); err != nil { + return fmt.Errorf("unmarshaling Inputs into dictionary map[string]json.RawMessage: %+v", err) + } + + output := make(map[string]JobInput) + for key, val := range dictionaryTemp { + impl, err := UnmarshalJobInputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling key %q field 'Inputs' for 'SweepJob': %+v", key, err) + } + output[key] = impl + } + s.Inputs = &output + } + + if v, ok := temp["outputs"]; ok { + var dictionaryTemp map[string]json.RawMessage + if err := json.Unmarshal(v, &dictionaryTemp); err != nil { + return fmt.Errorf("unmarshaling Outputs into dictionary map[string]json.RawMessage: %+v", err) + } + + output := make(map[string]JobOutput) + for key, val := range dictionaryTemp { + impl, err := UnmarshalJobOutputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling key %q field 'Outputs' for 'SweepJob': %+v", key, err) + } + output[key] = impl + } + s.Outputs = &output + } + + if v, ok := temp["samplingAlgorithm"]; ok { + impl, err := UnmarshalSamplingAlgorithmImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'SamplingAlgorithm' for 'SweepJob': %+v", err) + } + s.SamplingAlgorithm = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_sweepjoblimits.go b/resource-manager/machinelearningservices/2025-04-01/job/model_sweepjoblimits.go new file mode 100644 index 00000000000..454fac2fd83 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_sweepjoblimits.go @@ -0,0 +1,54 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobLimits = SweepJobLimits{} + +type SweepJobLimits struct { + MaxConcurrentTrials *int64 `json:"maxConcurrentTrials,omitempty"` + MaxTotalTrials *int64 `json:"maxTotalTrials,omitempty"` + TrialTimeout *string `json:"trialTimeout,omitempty"` + + // Fields inherited from JobLimits + + JobLimitsType JobLimitsType `json:"jobLimitsType"` + Timeout *string `json:"timeout,omitempty"` +} + +func (s SweepJobLimits) JobLimits() BaseJobLimitsImpl { + return BaseJobLimitsImpl{ + JobLimitsType: s.JobLimitsType, + Timeout: s.Timeout, + } +} + +var _ json.Marshaler = SweepJobLimits{} + +func (s SweepJobLimits) MarshalJSON() ([]byte, error) { + type wrapper SweepJobLimits + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SweepJobLimits: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SweepJobLimits: %+v", err) + } + + decoded["jobLimitsType"] = "Sweep" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SweepJobLimits: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_tableverticalfeaturizationsettings.go b/resource-manager/machinelearningservices/2025-04-01/job/model_tableverticalfeaturizationsettings.go new file mode 100644 index 00000000000..060dbfac742 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_tableverticalfeaturizationsettings.go @@ -0,0 +1,13 @@ +package job + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TableVerticalFeaturizationSettings struct { + BlockedTransformers *[]BlockedTransformers `json:"blockedTransformers,omitempty"` + ColumnNameAndTypes *map[string]string `json:"columnNameAndTypes,omitempty"` + DatasetLanguage *string `json:"datasetLanguage,omitempty"` + EnableDnnFeaturization *bool `json:"enableDnnFeaturization,omitempty"` + Mode *FeaturizationMode `json:"mode,omitempty"` + TransformerParams *map[string][]ColumnTransformer `json:"transformerParams,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_tableverticallimitsettings.go b/resource-manager/machinelearningservices/2025-04-01/job/model_tableverticallimitsettings.go new file mode 100644 index 00000000000..82dfb34cd79 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_tableverticallimitsettings.go @@ -0,0 +1,14 @@ +package job + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TableVerticalLimitSettings struct { + EnableEarlyTermination *bool `json:"enableEarlyTermination,omitempty"` + ExitScore *float64 `json:"exitScore,omitempty"` + MaxConcurrentTrials *int64 `json:"maxConcurrentTrials,omitempty"` + MaxCoresPerTrial *int64 `json:"maxCoresPerTrial,omitempty"` + MaxTrials *int64 `json:"maxTrials,omitempty"` + Timeout *string `json:"timeout,omitempty"` + TrialTimeout *string `json:"trialTimeout,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_targetlags.go b/resource-manager/machinelearningservices/2025-04-01/job/model_targetlags.go new file mode 100644 index 00000000000..6ddabc1f868 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_targetlags.go @@ -0,0 +1,83 @@ +package job + +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 TargetLags interface { + TargetLags() BaseTargetLagsImpl +} + +var _ TargetLags = BaseTargetLagsImpl{} + +type BaseTargetLagsImpl struct { + Mode TargetLagsMode `json:"mode"` +} + +func (s BaseTargetLagsImpl) TargetLags() BaseTargetLagsImpl { + return s +} + +var _ TargetLags = RawTargetLagsImpl{} + +// RawTargetLagsImpl 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 RawTargetLagsImpl struct { + targetLags BaseTargetLagsImpl + Type string + Values map[string]interface{} +} + +func (s RawTargetLagsImpl) TargetLags() BaseTargetLagsImpl { + return s.targetLags +} + +func UnmarshalTargetLagsImplementation(input []byte) (TargetLags, 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 TargetLags into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["mode"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Auto") { + var out AutoTargetLags + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AutoTargetLags: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Custom") { + var out CustomTargetLags + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CustomTargetLags: %+v", err) + } + return out, nil + } + + var parent BaseTargetLagsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseTargetLagsImpl: %+v", err) + } + + return RawTargetLagsImpl{ + targetLags: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_targetrollingwindowsize.go b/resource-manager/machinelearningservices/2025-04-01/job/model_targetrollingwindowsize.go new file mode 100644 index 00000000000..21b2b60ee50 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_targetrollingwindowsize.go @@ -0,0 +1,83 @@ +package job + +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 TargetRollingWindowSize interface { + TargetRollingWindowSize() BaseTargetRollingWindowSizeImpl +} + +var _ TargetRollingWindowSize = BaseTargetRollingWindowSizeImpl{} + +type BaseTargetRollingWindowSizeImpl struct { + Mode TargetRollingWindowSizeMode `json:"mode"` +} + +func (s BaseTargetRollingWindowSizeImpl) TargetRollingWindowSize() BaseTargetRollingWindowSizeImpl { + return s +} + +var _ TargetRollingWindowSize = RawTargetRollingWindowSizeImpl{} + +// RawTargetRollingWindowSizeImpl 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 RawTargetRollingWindowSizeImpl struct { + targetRollingWindowSize BaseTargetRollingWindowSizeImpl + Type string + Values map[string]interface{} +} + +func (s RawTargetRollingWindowSizeImpl) TargetRollingWindowSize() BaseTargetRollingWindowSizeImpl { + return s.targetRollingWindowSize +} + +func UnmarshalTargetRollingWindowSizeImplementation(input []byte) (TargetRollingWindowSize, 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 TargetRollingWindowSize into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["mode"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Auto") { + var out AutoTargetRollingWindowSize + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AutoTargetRollingWindowSize: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Custom") { + var out CustomTargetRollingWindowSize + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CustomTargetRollingWindowSize: %+v", err) + } + return out, nil + } + + var parent BaseTargetRollingWindowSizeImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseTargetRollingWindowSizeImpl: %+v", err) + } + + return RawTargetRollingWindowSizeImpl{ + targetRollingWindowSize: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_tensorflow.go b/resource-manager/machinelearningservices/2025-04-01/job/model_tensorflow.go new file mode 100644 index 00000000000..3c253e1be1f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_tensorflow.go @@ -0,0 +1,51 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DistributionConfiguration = TensorFlow{} + +type TensorFlow struct { + ParameterServerCount *int64 `json:"parameterServerCount,omitempty"` + WorkerCount *int64 `json:"workerCount,omitempty"` + + // Fields inherited from DistributionConfiguration + + DistributionType DistributionType `json:"distributionType"` +} + +func (s TensorFlow) DistributionConfiguration() BaseDistributionConfigurationImpl { + return BaseDistributionConfigurationImpl{ + DistributionType: s.DistributionType, + } +} + +var _ json.Marshaler = TensorFlow{} + +func (s TensorFlow) MarshalJSON() ([]byte, error) { + type wrapper TensorFlow + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling TensorFlow: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling TensorFlow: %+v", err) + } + + decoded["distributionType"] = "TensorFlow" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling TensorFlow: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_textclassification.go b/resource-manager/machinelearningservices/2025-04-01/job/model_textclassification.go new file mode 100644 index 00000000000..2931cc4b784 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_textclassification.go @@ -0,0 +1,59 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AutoMLVertical = TextClassification{} + +type TextClassification struct { + FeaturizationSettings *FeaturizationSettings `json:"featurizationSettings,omitempty"` + LimitSettings *NlpVerticalLimitSettings `json:"limitSettings,omitempty"` + PrimaryMetric *ClassificationPrimaryMetrics `json:"primaryMetric,omitempty"` + ValidationData *MLTableJobInput `json:"validationData,omitempty"` + + // Fields inherited from AutoMLVertical + + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` +} + +func (s TextClassification) AutoMLVertical() BaseAutoMLVerticalImpl { + return BaseAutoMLVerticalImpl{ + LogVerbosity: s.LogVerbosity, + TargetColumnName: s.TargetColumnName, + TaskType: s.TaskType, + TrainingData: s.TrainingData, + } +} + +var _ json.Marshaler = TextClassification{} + +func (s TextClassification) MarshalJSON() ([]byte, error) { + type wrapper TextClassification + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling TextClassification: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling TextClassification: %+v", err) + } + + decoded["taskType"] = "TextClassification" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling TextClassification: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_textclassificationmultilabel.go b/resource-manager/machinelearningservices/2025-04-01/job/model_textclassificationmultilabel.go new file mode 100644 index 00000000000..a6c15773558 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_textclassificationmultilabel.go @@ -0,0 +1,59 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AutoMLVertical = TextClassificationMultilabel{} + +type TextClassificationMultilabel struct { + FeaturizationSettings *FeaturizationSettings `json:"featurizationSettings,omitempty"` + LimitSettings *NlpVerticalLimitSettings `json:"limitSettings,omitempty"` + PrimaryMetric *ClassificationMultilabelPrimaryMetrics `json:"primaryMetric,omitempty"` + ValidationData *MLTableJobInput `json:"validationData,omitempty"` + + // Fields inherited from AutoMLVertical + + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` +} + +func (s TextClassificationMultilabel) AutoMLVertical() BaseAutoMLVerticalImpl { + return BaseAutoMLVerticalImpl{ + LogVerbosity: s.LogVerbosity, + TargetColumnName: s.TargetColumnName, + TaskType: s.TaskType, + TrainingData: s.TrainingData, + } +} + +var _ json.Marshaler = TextClassificationMultilabel{} + +func (s TextClassificationMultilabel) MarshalJSON() ([]byte, error) { + type wrapper TextClassificationMultilabel + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling TextClassificationMultilabel: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling TextClassificationMultilabel: %+v", err) + } + + decoded["taskType"] = "TextClassificationMultilabel" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling TextClassificationMultilabel: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_textner.go b/resource-manager/machinelearningservices/2025-04-01/job/model_textner.go new file mode 100644 index 00000000000..481ae1e0a51 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_textner.go @@ -0,0 +1,59 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AutoMLVertical = TextNer{} + +type TextNer struct { + FeaturizationSettings *FeaturizationSettings `json:"featurizationSettings,omitempty"` + LimitSettings *NlpVerticalLimitSettings `json:"limitSettings,omitempty"` + PrimaryMetric *ClassificationPrimaryMetrics `json:"primaryMetric,omitempty"` + ValidationData *MLTableJobInput `json:"validationData,omitempty"` + + // Fields inherited from AutoMLVertical + + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` +} + +func (s TextNer) AutoMLVertical() BaseAutoMLVerticalImpl { + return BaseAutoMLVerticalImpl{ + LogVerbosity: s.LogVerbosity, + TargetColumnName: s.TargetColumnName, + TaskType: s.TaskType, + TrainingData: s.TrainingData, + } +} + +var _ json.Marshaler = TextNer{} + +func (s TextNer) MarshalJSON() ([]byte, error) { + type wrapper TextNer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling TextNer: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling TextNer: %+v", err) + } + + decoded["taskType"] = "TextNER" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling TextNer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_trialcomponent.go b/resource-manager/machinelearningservices/2025-04-01/job/model_trialcomponent.go new file mode 100644 index 00000000000..93d6145363f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_trialcomponent.go @@ -0,0 +1,54 @@ +package job + +import ( + "encoding/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 TrialComponent struct { + CodeId *string `json:"codeId,omitempty"` + Command string `json:"command"` + Distribution DistributionConfiguration `json:"distribution"` + EnvironmentId string `json:"environmentId"` + EnvironmentVariables *map[string]string `json:"environmentVariables,omitempty"` + Resources *JobResourceConfiguration `json:"resources,omitempty"` +} + +var _ json.Unmarshaler = &TrialComponent{} + +func (s *TrialComponent) UnmarshalJSON(bytes []byte) error { + var decoded struct { + CodeId *string `json:"codeId,omitempty"` + Command string `json:"command"` + EnvironmentId string `json:"environmentId"` + EnvironmentVariables *map[string]string `json:"environmentVariables,omitempty"` + Resources *JobResourceConfiguration `json:"resources,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.CodeId = decoded.CodeId + s.Command = decoded.Command + s.EnvironmentId = decoded.EnvironmentId + s.EnvironmentVariables = decoded.EnvironmentVariables + s.Resources = decoded.Resources + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling TrialComponent into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["distribution"]; ok { + impl, err := UnmarshalDistributionConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Distribution' for 'TrialComponent': %+v", err) + } + s.Distribution = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_tritonmodeljobinput.go b/resource-manager/machinelearningservices/2025-04-01/job/model_tritonmodeljobinput.go new file mode 100644 index 00000000000..cb1aa8e5955 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_tritonmodeljobinput.go @@ -0,0 +1,53 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobInput = TritonModelJobInput{} + +type TritonModelJobInput struct { + Mode *InputDeliveryMode `json:"mode,omitempty"` + Uri string `json:"uri"` + + // Fields inherited from JobInput + + Description *string `json:"description,omitempty"` + JobInputType JobInputType `json:"jobInputType"` +} + +func (s TritonModelJobInput) JobInput() BaseJobInputImpl { + return BaseJobInputImpl{ + Description: s.Description, + JobInputType: s.JobInputType, + } +} + +var _ json.Marshaler = TritonModelJobInput{} + +func (s TritonModelJobInput) MarshalJSON() ([]byte, error) { + type wrapper TritonModelJobInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling TritonModelJobInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling TritonModelJobInput: %+v", err) + } + + decoded["jobInputType"] = "triton_model" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling TritonModelJobInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_tritonmodeljoboutput.go b/resource-manager/machinelearningservices/2025-04-01/job/model_tritonmodeljoboutput.go new file mode 100644 index 00000000000..c01b418e890 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_tritonmodeljoboutput.go @@ -0,0 +1,53 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobOutput = TritonModelJobOutput{} + +type TritonModelJobOutput struct { + Mode *OutputDeliveryMode `json:"mode,omitempty"` + Uri *string `json:"uri,omitempty"` + + // Fields inherited from JobOutput + + Description *string `json:"description,omitempty"` + JobOutputType JobOutputType `json:"jobOutputType"` +} + +func (s TritonModelJobOutput) JobOutput() BaseJobOutputImpl { + return BaseJobOutputImpl{ + Description: s.Description, + JobOutputType: s.JobOutputType, + } +} + +var _ json.Marshaler = TritonModelJobOutput{} + +func (s TritonModelJobOutput) MarshalJSON() ([]byte, error) { + type wrapper TritonModelJobOutput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling TritonModelJobOutput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling TritonModelJobOutput: %+v", err) + } + + decoded["jobOutputType"] = "triton_model" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling TritonModelJobOutput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_truncationselectionpolicy.go b/resource-manager/machinelearningservices/2025-04-01/job/model_truncationselectionpolicy.go new file mode 100644 index 00000000000..6f7bdc5a76d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_truncationselectionpolicy.go @@ -0,0 +1,54 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EarlyTerminationPolicy = TruncationSelectionPolicy{} + +type TruncationSelectionPolicy struct { + TruncationPercentage *int64 `json:"truncationPercentage,omitempty"` + + // Fields inherited from EarlyTerminationPolicy + + DelayEvaluation *int64 `json:"delayEvaluation,omitempty"` + EvaluationInterval *int64 `json:"evaluationInterval,omitempty"` + PolicyType EarlyTerminationPolicyType `json:"policyType"` +} + +func (s TruncationSelectionPolicy) EarlyTerminationPolicy() BaseEarlyTerminationPolicyImpl { + return BaseEarlyTerminationPolicyImpl{ + DelayEvaluation: s.DelayEvaluation, + EvaluationInterval: s.EvaluationInterval, + PolicyType: s.PolicyType, + } +} + +var _ json.Marshaler = TruncationSelectionPolicy{} + +func (s TruncationSelectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper TruncationSelectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling TruncationSelectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling TruncationSelectionPolicy: %+v", err) + } + + decoded["policyType"] = "TruncationSelection" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling TruncationSelectionPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_urifilejobinput.go b/resource-manager/machinelearningservices/2025-04-01/job/model_urifilejobinput.go new file mode 100644 index 00000000000..da8491b514b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_urifilejobinput.go @@ -0,0 +1,53 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobInput = UriFileJobInput{} + +type UriFileJobInput struct { + Mode *InputDeliveryMode `json:"mode,omitempty"` + Uri string `json:"uri"` + + // Fields inherited from JobInput + + Description *string `json:"description,omitempty"` + JobInputType JobInputType `json:"jobInputType"` +} + +func (s UriFileJobInput) JobInput() BaseJobInputImpl { + return BaseJobInputImpl{ + Description: s.Description, + JobInputType: s.JobInputType, + } +} + +var _ json.Marshaler = UriFileJobInput{} + +func (s UriFileJobInput) MarshalJSON() ([]byte, error) { + type wrapper UriFileJobInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling UriFileJobInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling UriFileJobInput: %+v", err) + } + + decoded["jobInputType"] = "uri_file" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling UriFileJobInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_urifilejoboutput.go b/resource-manager/machinelearningservices/2025-04-01/job/model_urifilejoboutput.go new file mode 100644 index 00000000000..2e0588a2aed --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_urifilejoboutput.go @@ -0,0 +1,53 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobOutput = UriFileJobOutput{} + +type UriFileJobOutput struct { + Mode *OutputDeliveryMode `json:"mode,omitempty"` + Uri *string `json:"uri,omitempty"` + + // Fields inherited from JobOutput + + Description *string `json:"description,omitempty"` + JobOutputType JobOutputType `json:"jobOutputType"` +} + +func (s UriFileJobOutput) JobOutput() BaseJobOutputImpl { + return BaseJobOutputImpl{ + Description: s.Description, + JobOutputType: s.JobOutputType, + } +} + +var _ json.Marshaler = UriFileJobOutput{} + +func (s UriFileJobOutput) MarshalJSON() ([]byte, error) { + type wrapper UriFileJobOutput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling UriFileJobOutput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling UriFileJobOutput: %+v", err) + } + + decoded["jobOutputType"] = "uri_file" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling UriFileJobOutput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_urifolderjobinput.go b/resource-manager/machinelearningservices/2025-04-01/job/model_urifolderjobinput.go new file mode 100644 index 00000000000..93d54a955c6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_urifolderjobinput.go @@ -0,0 +1,53 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobInput = UriFolderJobInput{} + +type UriFolderJobInput struct { + Mode *InputDeliveryMode `json:"mode,omitempty"` + Uri string `json:"uri"` + + // Fields inherited from JobInput + + Description *string `json:"description,omitempty"` + JobInputType JobInputType `json:"jobInputType"` +} + +func (s UriFolderJobInput) JobInput() BaseJobInputImpl { + return BaseJobInputImpl{ + Description: s.Description, + JobInputType: s.JobInputType, + } +} + +var _ json.Marshaler = UriFolderJobInput{} + +func (s UriFolderJobInput) MarshalJSON() ([]byte, error) { + type wrapper UriFolderJobInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling UriFolderJobInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling UriFolderJobInput: %+v", err) + } + + decoded["jobInputType"] = "uri_folder" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling UriFolderJobInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_urifolderjoboutput.go b/resource-manager/machinelearningservices/2025-04-01/job/model_urifolderjoboutput.go new file mode 100644 index 00000000000..368d535cedd --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_urifolderjoboutput.go @@ -0,0 +1,53 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobOutput = UriFolderJobOutput{} + +type UriFolderJobOutput struct { + Mode *OutputDeliveryMode `json:"mode,omitempty"` + Uri *string `json:"uri,omitempty"` + + // Fields inherited from JobOutput + + Description *string `json:"description,omitempty"` + JobOutputType JobOutputType `json:"jobOutputType"` +} + +func (s UriFolderJobOutput) JobOutput() BaseJobOutputImpl { + return BaseJobOutputImpl{ + Description: s.Description, + JobOutputType: s.JobOutputType, + } +} + +var _ json.Marshaler = UriFolderJobOutput{} + +func (s UriFolderJobOutput) MarshalJSON() ([]byte, error) { + type wrapper UriFolderJobOutput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling UriFolderJobOutput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling UriFolderJobOutput: %+v", err) + } + + decoded["jobOutputType"] = "uri_folder" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling UriFolderJobOutput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_useridentity.go b/resource-manager/machinelearningservices/2025-04-01/job/model_useridentity.go new file mode 100644 index 00000000000..938c1408fc4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_useridentity.go @@ -0,0 +1,49 @@ +package job + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ IdentityConfiguration = UserIdentity{} + +type UserIdentity struct { + + // Fields inherited from IdentityConfiguration + + IdentityType IdentityConfigurationType `json:"identityType"` +} + +func (s UserIdentity) IdentityConfiguration() BaseIdentityConfigurationImpl { + return BaseIdentityConfigurationImpl{ + IdentityType: s.IdentityType, + } +} + +var _ json.Marshaler = UserIdentity{} + +func (s UserIdentity) MarshalJSON() ([]byte, error) { + type wrapper UserIdentity + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling UserIdentity: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling UserIdentity: %+v", err) + } + + decoded["identityType"] = "UserIdentity" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling UserIdentity: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/model_webhook.go b/resource-manager/machinelearningservices/2025-04-01/job/model_webhook.go new file mode 100644 index 00000000000..ce5c5b53745 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/model_webhook.go @@ -0,0 +1,76 @@ +package job + +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 Webhook interface { + Webhook() BaseWebhookImpl +} + +var _ Webhook = BaseWebhookImpl{} + +type BaseWebhookImpl struct { + EventType *string `json:"eventType,omitempty"` + WebhookType WebhookType `json:"webhookType"` +} + +func (s BaseWebhookImpl) Webhook() BaseWebhookImpl { + return s +} + +var _ Webhook = RawWebhookImpl{} + +// RawWebhookImpl 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 RawWebhookImpl struct { + webhook BaseWebhookImpl + Type string + Values map[string]interface{} +} + +func (s RawWebhookImpl) Webhook() BaseWebhookImpl { + return s.webhook +} + +func UnmarshalWebhookImplementation(input []byte) (Webhook, 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 Webhook into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["webhookType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AzureDevOps") { + var out AzureDevOpsWebhook + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureDevOpsWebhook: %+v", err) + } + return out, nil + } + + var parent BaseWebhookImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseWebhookImpl: %+v", err) + } + + return RawWebhookImpl{ + webhook: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/job/predicates.go b/resource-manager/machinelearningservices/2025-04-01/job/predicates.go new file mode 100644 index 00000000000..aa1d8495bd3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/predicates.go @@ -0,0 +1,27 @@ +package job + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobBaseResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p JobBaseResourceOperationPredicate) Matches(input JobBaseResource) 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/machinelearningservices/2025-04-01/job/version.go b/resource-manager/machinelearningservices/2025-04-01/job/version.go new file mode 100644 index 00000000000..d9339df351e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/job/version.go @@ -0,0 +1,10 @@ +package job + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/job/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/README.md b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/README.md new file mode 100644 index 00000000000..d560ca83a4c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/README.md @@ -0,0 +1,168 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes` Documentation + +The `machinelearningcomputes` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes" +``` + + +### Client Initialization + +```go +client := machinelearningcomputes.NewMachineLearningComputesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `MachineLearningComputesClient.ComputeCreateOrUpdate` + +```go +ctx := context.TODO() +id := machinelearningcomputes.NewComputeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "computeName") + +payload := machinelearningcomputes.ComputeResource{ + // ... +} + + +if err := client.ComputeCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `MachineLearningComputesClient.ComputeDelete` + +```go +ctx := context.TODO() +id := machinelearningcomputes.NewComputeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "computeName") + +if err := client.ComputeDeleteThenPoll(ctx, id, machinelearningcomputes.DefaultComputeDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `MachineLearningComputesClient.ComputeGet` + +```go +ctx := context.TODO() +id := machinelearningcomputes.NewComputeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "computeName") + +read, err := client.ComputeGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `MachineLearningComputesClient.ComputeList` + +```go +ctx := context.TODO() +id := machinelearningcomputes.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +// alternatively `client.ComputeList(ctx, id, machinelearningcomputes.DefaultComputeListOperationOptions())` can be used to do batched pagination +items, err := client.ComputeListComplete(ctx, id, machinelearningcomputes.DefaultComputeListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `MachineLearningComputesClient.ComputeListKeys` + +```go +ctx := context.TODO() +id := machinelearningcomputes.NewComputeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "computeName") + +read, err := client.ComputeListKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `MachineLearningComputesClient.ComputeListNodes` + +```go +ctx := context.TODO() +id := machinelearningcomputes.NewComputeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "computeName") + +// alternatively `client.ComputeListNodes(ctx, id)` can be used to do batched pagination +items, err := client.ComputeListNodesComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `MachineLearningComputesClient.ComputeRestart` + +```go +ctx := context.TODO() +id := machinelearningcomputes.NewComputeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "computeName") + +if err := client.ComputeRestartThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `MachineLearningComputesClient.ComputeStart` + +```go +ctx := context.TODO() +id := machinelearningcomputes.NewComputeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "computeName") + +if err := client.ComputeStartThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `MachineLearningComputesClient.ComputeStop` + +```go +ctx := context.TODO() +id := machinelearningcomputes.NewComputeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "computeName") + +if err := client.ComputeStopThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `MachineLearningComputesClient.ComputeUpdate` + +```go +ctx := context.TODO() +id := machinelearningcomputes.NewComputeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "computeName") + +payload := machinelearningcomputes.ClusterUpdateParameters{ + // ... +} + + +if err := client.ComputeUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/client.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/client.go new file mode 100644 index 00000000000..7c06a2fa111 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/client.go @@ -0,0 +1,26 @@ +package machinelearningcomputes + +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 MachineLearningComputesClient struct { + Client *resourcemanager.Client +} + +func NewMachineLearningComputesClientWithBaseURI(sdkApi sdkEnv.Api) (*MachineLearningComputesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "machinelearningcomputes", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating MachineLearningComputesClient: %+v", err) + } + + return &MachineLearningComputesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/constants.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/constants.go new file mode 100644 index 00000000000..890aae53905 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/constants.go @@ -0,0 +1,1719 @@ +package machinelearningcomputes + +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 AllocationState string + +const ( + AllocationStateResizing AllocationState = "Resizing" + AllocationStateSteady AllocationState = "Steady" +) + +func PossibleValuesForAllocationState() []string { + return []string{ + string(AllocationStateResizing), + string(AllocationStateSteady), + } +} + +func (s *AllocationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAllocationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAllocationState(input string) (*AllocationState, error) { + vals := map[string]AllocationState{ + "resizing": AllocationStateResizing, + "steady": AllocationStateSteady, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AllocationState(input) + return &out, nil +} + +type ApplicationSharingPolicy string + +const ( + ApplicationSharingPolicyPersonal ApplicationSharingPolicy = "Personal" + ApplicationSharingPolicyShared ApplicationSharingPolicy = "Shared" +) + +func PossibleValuesForApplicationSharingPolicy() []string { + return []string{ + string(ApplicationSharingPolicyPersonal), + string(ApplicationSharingPolicyShared), + } +} + +func (s *ApplicationSharingPolicy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationSharingPolicy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationSharingPolicy(input string) (*ApplicationSharingPolicy, error) { + vals := map[string]ApplicationSharingPolicy{ + "personal": ApplicationSharingPolicyPersonal, + "shared": ApplicationSharingPolicyShared, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationSharingPolicy(input) + return &out, nil +} + +type Autosave string + +const ( + AutosaveLocal Autosave = "Local" + AutosaveNone Autosave = "None" + AutosaveRemote Autosave = "Remote" +) + +func PossibleValuesForAutosave() []string { + return []string{ + string(AutosaveLocal), + string(AutosaveNone), + string(AutosaveRemote), + } +} + +func (s *Autosave) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutosave(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutosave(input string) (*Autosave, error) { + vals := map[string]Autosave{ + "local": AutosaveLocal, + "none": AutosaveNone, + "remote": AutosaveRemote, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Autosave(input) + return &out, nil +} + +type Caching string + +const ( + CachingNone Caching = "None" + CachingReadOnly Caching = "ReadOnly" + CachingReadWrite Caching = "ReadWrite" +) + +func PossibleValuesForCaching() []string { + return []string{ + string(CachingNone), + string(CachingReadOnly), + string(CachingReadWrite), + } +} + +func (s *Caching) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCaching(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCaching(input string) (*Caching, error) { + vals := map[string]Caching{ + "none": CachingNone, + "readonly": CachingReadOnly, + "readwrite": CachingReadWrite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Caching(input) + return &out, nil +} + +type ClusterPurpose string + +const ( + ClusterPurposeDenseProd ClusterPurpose = "DenseProd" + ClusterPurposeDevTest ClusterPurpose = "DevTest" + ClusterPurposeFastProd ClusterPurpose = "FastProd" +) + +func PossibleValuesForClusterPurpose() []string { + return []string{ + string(ClusterPurposeDenseProd), + string(ClusterPurposeDevTest), + string(ClusterPurposeFastProd), + } +} + +func (s *ClusterPurpose) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterPurpose(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterPurpose(input string) (*ClusterPurpose, error) { + vals := map[string]ClusterPurpose{ + "denseprod": ClusterPurposeDenseProd, + "devtest": ClusterPurposeDevTest, + "fastprod": ClusterPurposeFastProd, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterPurpose(input) + return &out, nil +} + +type ComputeInstanceAuthorizationType string + +const ( + ComputeInstanceAuthorizationTypePersonal ComputeInstanceAuthorizationType = "personal" +) + +func PossibleValuesForComputeInstanceAuthorizationType() []string { + return []string{ + string(ComputeInstanceAuthorizationTypePersonal), + } +} + +func (s *ComputeInstanceAuthorizationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseComputeInstanceAuthorizationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseComputeInstanceAuthorizationType(input string) (*ComputeInstanceAuthorizationType, error) { + vals := map[string]ComputeInstanceAuthorizationType{ + "personal": ComputeInstanceAuthorizationTypePersonal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ComputeInstanceAuthorizationType(input) + return &out, nil +} + +type ComputeInstanceState string + +const ( + ComputeInstanceStateCreateFailed ComputeInstanceState = "CreateFailed" + ComputeInstanceStateCreating ComputeInstanceState = "Creating" + ComputeInstanceStateDeleting ComputeInstanceState = "Deleting" + ComputeInstanceStateJobRunning ComputeInstanceState = "JobRunning" + ComputeInstanceStateRestarting ComputeInstanceState = "Restarting" + ComputeInstanceStateRunning ComputeInstanceState = "Running" + ComputeInstanceStateSettingUp ComputeInstanceState = "SettingUp" + ComputeInstanceStateSetupFailed ComputeInstanceState = "SetupFailed" + ComputeInstanceStateStarting ComputeInstanceState = "Starting" + ComputeInstanceStateStopped ComputeInstanceState = "Stopped" + ComputeInstanceStateStopping ComputeInstanceState = "Stopping" + ComputeInstanceStateUnknown ComputeInstanceState = "Unknown" + ComputeInstanceStateUnusable ComputeInstanceState = "Unusable" + ComputeInstanceStateUserSettingUp ComputeInstanceState = "UserSettingUp" + ComputeInstanceStateUserSetupFailed ComputeInstanceState = "UserSetupFailed" +) + +func PossibleValuesForComputeInstanceState() []string { + return []string{ + string(ComputeInstanceStateCreateFailed), + string(ComputeInstanceStateCreating), + string(ComputeInstanceStateDeleting), + string(ComputeInstanceStateJobRunning), + string(ComputeInstanceStateRestarting), + string(ComputeInstanceStateRunning), + string(ComputeInstanceStateSettingUp), + string(ComputeInstanceStateSetupFailed), + string(ComputeInstanceStateStarting), + string(ComputeInstanceStateStopped), + string(ComputeInstanceStateStopping), + string(ComputeInstanceStateUnknown), + string(ComputeInstanceStateUnusable), + string(ComputeInstanceStateUserSettingUp), + string(ComputeInstanceStateUserSetupFailed), + } +} + +func (s *ComputeInstanceState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseComputeInstanceState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseComputeInstanceState(input string) (*ComputeInstanceState, error) { + vals := map[string]ComputeInstanceState{ + "createfailed": ComputeInstanceStateCreateFailed, + "creating": ComputeInstanceStateCreating, + "deleting": ComputeInstanceStateDeleting, + "jobrunning": ComputeInstanceStateJobRunning, + "restarting": ComputeInstanceStateRestarting, + "running": ComputeInstanceStateRunning, + "settingup": ComputeInstanceStateSettingUp, + "setupfailed": ComputeInstanceStateSetupFailed, + "starting": ComputeInstanceStateStarting, + "stopped": ComputeInstanceStateStopped, + "stopping": ComputeInstanceStateStopping, + "unknown": ComputeInstanceStateUnknown, + "unusable": ComputeInstanceStateUnusable, + "usersettingup": ComputeInstanceStateUserSettingUp, + "usersetupfailed": ComputeInstanceStateUserSetupFailed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ComputeInstanceState(input) + return &out, nil +} + +type ComputePowerAction string + +const ( + ComputePowerActionStart ComputePowerAction = "Start" + ComputePowerActionStop ComputePowerAction = "Stop" +) + +func PossibleValuesForComputePowerAction() []string { + return []string{ + string(ComputePowerActionStart), + string(ComputePowerActionStop), + } +} + +func (s *ComputePowerAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseComputePowerAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseComputePowerAction(input string) (*ComputePowerAction, error) { + vals := map[string]ComputePowerAction{ + "start": ComputePowerActionStart, + "stop": ComputePowerActionStop, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ComputePowerAction(input) + return &out, nil +} + +type ComputeRecurrenceFrequency string + +const ( + ComputeRecurrenceFrequencyDay ComputeRecurrenceFrequency = "Day" + ComputeRecurrenceFrequencyHour ComputeRecurrenceFrequency = "Hour" + ComputeRecurrenceFrequencyMinute ComputeRecurrenceFrequency = "Minute" + ComputeRecurrenceFrequencyMonth ComputeRecurrenceFrequency = "Month" + ComputeRecurrenceFrequencyWeek ComputeRecurrenceFrequency = "Week" +) + +func PossibleValuesForComputeRecurrenceFrequency() []string { + return []string{ + string(ComputeRecurrenceFrequencyDay), + string(ComputeRecurrenceFrequencyHour), + string(ComputeRecurrenceFrequencyMinute), + string(ComputeRecurrenceFrequencyMonth), + string(ComputeRecurrenceFrequencyWeek), + } +} + +func (s *ComputeRecurrenceFrequency) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseComputeRecurrenceFrequency(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseComputeRecurrenceFrequency(input string) (*ComputeRecurrenceFrequency, error) { + vals := map[string]ComputeRecurrenceFrequency{ + "day": ComputeRecurrenceFrequencyDay, + "hour": ComputeRecurrenceFrequencyHour, + "minute": ComputeRecurrenceFrequencyMinute, + "month": ComputeRecurrenceFrequencyMonth, + "week": ComputeRecurrenceFrequencyWeek, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ComputeRecurrenceFrequency(input) + return &out, nil +} + +type ComputeTriggerType string + +const ( + ComputeTriggerTypeCron ComputeTriggerType = "Cron" + ComputeTriggerTypeRecurrence ComputeTriggerType = "Recurrence" +) + +func PossibleValuesForComputeTriggerType() []string { + return []string{ + string(ComputeTriggerTypeCron), + string(ComputeTriggerTypeRecurrence), + } +} + +func (s *ComputeTriggerType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseComputeTriggerType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseComputeTriggerType(input string) (*ComputeTriggerType, error) { + vals := map[string]ComputeTriggerType{ + "cron": ComputeTriggerTypeCron, + "recurrence": ComputeTriggerTypeRecurrence, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ComputeTriggerType(input) + return &out, nil +} + +type ComputeType string + +const ( + ComputeTypeAKS ComputeType = "AKS" + ComputeTypeAmlCompute ComputeType = "AmlCompute" + ComputeTypeComputeInstance ComputeType = "ComputeInstance" + ComputeTypeDataFactory ComputeType = "DataFactory" + ComputeTypeDataLakeAnalytics ComputeType = "DataLakeAnalytics" + ComputeTypeDatabricks ComputeType = "Databricks" + ComputeTypeHDInsight ComputeType = "HDInsight" + ComputeTypeKubernetes ComputeType = "Kubernetes" + ComputeTypeSynapseSpark ComputeType = "SynapseSpark" + ComputeTypeVirtualMachine ComputeType = "VirtualMachine" +) + +func PossibleValuesForComputeType() []string { + return []string{ + string(ComputeTypeAKS), + string(ComputeTypeAmlCompute), + string(ComputeTypeComputeInstance), + string(ComputeTypeDataFactory), + string(ComputeTypeDataLakeAnalytics), + string(ComputeTypeDatabricks), + string(ComputeTypeHDInsight), + string(ComputeTypeKubernetes), + string(ComputeTypeSynapseSpark), + string(ComputeTypeVirtualMachine), + } +} + +func (s *ComputeType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseComputeType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseComputeType(input string) (*ComputeType, error) { + vals := map[string]ComputeType{ + "aks": ComputeTypeAKS, + "amlcompute": ComputeTypeAmlCompute, + "computeinstance": ComputeTypeComputeInstance, + "datafactory": ComputeTypeDataFactory, + "datalakeanalytics": ComputeTypeDataLakeAnalytics, + "databricks": ComputeTypeDatabricks, + "hdinsight": ComputeTypeHDInsight, + "kubernetes": ComputeTypeKubernetes, + "synapsespark": ComputeTypeSynapseSpark, + "virtualmachine": ComputeTypeVirtualMachine, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ComputeType(input) + return &out, nil +} + +type ComputeWeekDay string + +const ( + ComputeWeekDayFriday ComputeWeekDay = "Friday" + ComputeWeekDayMonday ComputeWeekDay = "Monday" + ComputeWeekDaySaturday ComputeWeekDay = "Saturday" + ComputeWeekDaySunday ComputeWeekDay = "Sunday" + ComputeWeekDayThursday ComputeWeekDay = "Thursday" + ComputeWeekDayTuesday ComputeWeekDay = "Tuesday" + ComputeWeekDayWednesday ComputeWeekDay = "Wednesday" +) + +func PossibleValuesForComputeWeekDay() []string { + return []string{ + string(ComputeWeekDayFriday), + string(ComputeWeekDayMonday), + string(ComputeWeekDaySaturday), + string(ComputeWeekDaySunday), + string(ComputeWeekDayThursday), + string(ComputeWeekDayTuesday), + string(ComputeWeekDayWednesday), + } +} + +func (s *ComputeWeekDay) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseComputeWeekDay(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseComputeWeekDay(input string) (*ComputeWeekDay, error) { + vals := map[string]ComputeWeekDay{ + "friday": ComputeWeekDayFriday, + "monday": ComputeWeekDayMonday, + "saturday": ComputeWeekDaySaturday, + "sunday": ComputeWeekDaySunday, + "thursday": ComputeWeekDayThursday, + "tuesday": ComputeWeekDayTuesday, + "wednesday": ComputeWeekDayWednesday, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ComputeWeekDay(input) + return &out, nil +} + +type EnvironmentVariableType string + +const ( + EnvironmentVariableTypeLocal EnvironmentVariableType = "local" +) + +func PossibleValuesForEnvironmentVariableType() []string { + return []string{ + string(EnvironmentVariableTypeLocal), + } +} + +func (s *EnvironmentVariableType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnvironmentVariableType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEnvironmentVariableType(input string) (*EnvironmentVariableType, error) { + vals := map[string]EnvironmentVariableType{ + "local": EnvironmentVariableTypeLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EnvironmentVariableType(input) + return &out, nil +} + +type ImageType string + +const ( + ImageTypeAzureml ImageType = "azureml" + ImageTypeDocker ImageType = "docker" +) + +func PossibleValuesForImageType() []string { + return []string{ + string(ImageTypeAzureml), + string(ImageTypeDocker), + } +} + +func (s *ImageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseImageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseImageType(input string) (*ImageType, error) { + vals := map[string]ImageType{ + "azureml": ImageTypeAzureml, + "docker": ImageTypeDocker, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ImageType(input) + return &out, nil +} + +type LoadBalancerType string + +const ( + LoadBalancerTypeInternalLoadBalancer LoadBalancerType = "InternalLoadBalancer" + LoadBalancerTypePublicIP LoadBalancerType = "PublicIp" +) + +func PossibleValuesForLoadBalancerType() []string { + return []string{ + string(LoadBalancerTypeInternalLoadBalancer), + string(LoadBalancerTypePublicIP), + } +} + +func (s *LoadBalancerType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerType(input string) (*LoadBalancerType, error) { + vals := map[string]LoadBalancerType{ + "internalloadbalancer": LoadBalancerTypeInternalLoadBalancer, + "publicip": LoadBalancerTypePublicIP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerType(input) + return &out, nil +} + +type MountAction string + +const ( + MountActionMount MountAction = "Mount" + MountActionUnmount MountAction = "Unmount" +) + +func PossibleValuesForMountAction() []string { + return []string{ + string(MountActionMount), + string(MountActionUnmount), + } +} + +func (s *MountAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMountAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMountAction(input string) (*MountAction, error) { + vals := map[string]MountAction{ + "mount": MountActionMount, + "unmount": MountActionUnmount, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MountAction(input) + return &out, nil +} + +type MountState string + +const ( + MountStateMountFailed MountState = "MountFailed" + MountStateMountRequested MountState = "MountRequested" + MountStateMounted MountState = "Mounted" + MountStateUnmountFailed MountState = "UnmountFailed" + MountStateUnmountRequested MountState = "UnmountRequested" + MountStateUnmounted MountState = "Unmounted" +) + +func PossibleValuesForMountState() []string { + return []string{ + string(MountStateMountFailed), + string(MountStateMountRequested), + string(MountStateMounted), + string(MountStateUnmountFailed), + string(MountStateUnmountRequested), + string(MountStateUnmounted), + } +} + +func (s *MountState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMountState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMountState(input string) (*MountState, error) { + vals := map[string]MountState{ + "mountfailed": MountStateMountFailed, + "mountrequested": MountStateMountRequested, + "mounted": MountStateMounted, + "unmountfailed": MountStateUnmountFailed, + "unmountrequested": MountStateUnmountRequested, + "unmounted": MountStateUnmounted, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MountState(input) + return &out, nil +} + +type Network string + +const ( + NetworkBridge Network = "Bridge" + NetworkHost Network = "Host" +) + +func PossibleValuesForNetwork() []string { + return []string{ + string(NetworkBridge), + string(NetworkHost), + } +} + +func (s *Network) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetwork(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetwork(input string) (*Network, error) { + vals := map[string]Network{ + "bridge": NetworkBridge, + "host": NetworkHost, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Network(input) + return &out, nil +} + +type NodeState string + +const ( + NodeStateIdle NodeState = "idle" + NodeStateLeaving NodeState = "leaving" + NodeStatePreempted NodeState = "preempted" + NodeStatePreparing NodeState = "preparing" + NodeStateRunning NodeState = "running" + NodeStateUnusable NodeState = "unusable" +) + +func PossibleValuesForNodeState() []string { + return []string{ + string(NodeStateIdle), + string(NodeStateLeaving), + string(NodeStatePreempted), + string(NodeStatePreparing), + string(NodeStateRunning), + string(NodeStateUnusable), + } +} + +func (s *NodeState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNodeState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNodeState(input string) (*NodeState, error) { + vals := map[string]NodeState{ + "idle": NodeStateIdle, + "leaving": NodeStateLeaving, + "preempted": NodeStatePreempted, + "preparing": NodeStatePreparing, + "running": NodeStateRunning, + "unusable": NodeStateUnusable, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NodeState(input) + return &out, nil +} + +type OperationName string + +const ( + OperationNameCreate OperationName = "Create" + OperationNameDelete OperationName = "Delete" + OperationNameReimage OperationName = "Reimage" + OperationNameRestart OperationName = "Restart" + OperationNameStart OperationName = "Start" + OperationNameStop OperationName = "Stop" +) + +func PossibleValuesForOperationName() []string { + return []string{ + string(OperationNameCreate), + string(OperationNameDelete), + string(OperationNameReimage), + string(OperationNameRestart), + string(OperationNameStart), + string(OperationNameStop), + } +} + +func (s *OperationName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperationName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOperationName(input string) (*OperationName, error) { + vals := map[string]OperationName{ + "create": OperationNameCreate, + "delete": OperationNameDelete, + "reimage": OperationNameReimage, + "restart": OperationNameRestart, + "start": OperationNameStart, + "stop": OperationNameStop, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OperationName(input) + return &out, nil +} + +type OperationStatus string + +const ( + OperationStatusCreateFailed OperationStatus = "CreateFailed" + OperationStatusDeleteFailed OperationStatus = "DeleteFailed" + OperationStatusInProgress OperationStatus = "InProgress" + OperationStatusReimageFailed OperationStatus = "ReimageFailed" + OperationStatusRestartFailed OperationStatus = "RestartFailed" + OperationStatusStartFailed OperationStatus = "StartFailed" + OperationStatusStopFailed OperationStatus = "StopFailed" + OperationStatusSucceeded OperationStatus = "Succeeded" +) + +func PossibleValuesForOperationStatus() []string { + return []string{ + string(OperationStatusCreateFailed), + string(OperationStatusDeleteFailed), + string(OperationStatusInProgress), + string(OperationStatusReimageFailed), + string(OperationStatusRestartFailed), + string(OperationStatusStartFailed), + string(OperationStatusStopFailed), + string(OperationStatusSucceeded), + } +} + +func (s *OperationStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperationStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOperationStatus(input string) (*OperationStatus, error) { + vals := map[string]OperationStatus{ + "createfailed": OperationStatusCreateFailed, + "deletefailed": OperationStatusDeleteFailed, + "inprogress": OperationStatusInProgress, + "reimagefailed": OperationStatusReimageFailed, + "restartfailed": OperationStatusRestartFailed, + "startfailed": OperationStatusStartFailed, + "stopfailed": OperationStatusStopFailed, + "succeeded": OperationStatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OperationStatus(input) + return &out, nil +} + +type OperationTrigger string + +const ( + OperationTriggerIdleShutdown OperationTrigger = "IdleShutdown" + OperationTriggerSchedule OperationTrigger = "Schedule" + OperationTriggerUser OperationTrigger = "User" +) + +func PossibleValuesForOperationTrigger() []string { + return []string{ + string(OperationTriggerIdleShutdown), + string(OperationTriggerSchedule), + string(OperationTriggerUser), + } +} + +func (s *OperationTrigger) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperationTrigger(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOperationTrigger(input string) (*OperationTrigger, error) { + vals := map[string]OperationTrigger{ + "idleshutdown": OperationTriggerIdleShutdown, + "schedule": OperationTriggerSchedule, + "user": OperationTriggerUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OperationTrigger(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 ( + ProtocolHTTP Protocol = "http" + ProtocolTcp Protocol = "tcp" + ProtocolUdp Protocol = "udp" +) + +func PossibleValuesForProtocol() []string { + return []string{ + string(ProtocolHTTP), + 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{ + "http": ProtocolHTTP, + "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 ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type ProvisioningStatus string + +const ( + ProvisioningStatusCompleted ProvisioningStatus = "Completed" + ProvisioningStatusFailed ProvisioningStatus = "Failed" + ProvisioningStatusProvisioning ProvisioningStatus = "Provisioning" +) + +func PossibleValuesForProvisioningStatus() []string { + return []string{ + string(ProvisioningStatusCompleted), + string(ProvisioningStatusFailed), + string(ProvisioningStatusProvisioning), + } +} + +func (s *ProvisioningStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningStatus(input string) (*ProvisioningStatus, error) { + vals := map[string]ProvisioningStatus{ + "completed": ProvisioningStatusCompleted, + "failed": ProvisioningStatusFailed, + "provisioning": ProvisioningStatusProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningStatus(input) + return &out, nil +} + +type RemoteLoginPortPublicAccess string + +const ( + RemoteLoginPortPublicAccessDisabled RemoteLoginPortPublicAccess = "Disabled" + RemoteLoginPortPublicAccessEnabled RemoteLoginPortPublicAccess = "Enabled" + RemoteLoginPortPublicAccessNotSpecified RemoteLoginPortPublicAccess = "NotSpecified" +) + +func PossibleValuesForRemoteLoginPortPublicAccess() []string { + return []string{ + string(RemoteLoginPortPublicAccessDisabled), + string(RemoteLoginPortPublicAccessEnabled), + string(RemoteLoginPortPublicAccessNotSpecified), + } +} + +func (s *RemoteLoginPortPublicAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRemoteLoginPortPublicAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRemoteLoginPortPublicAccess(input string) (*RemoteLoginPortPublicAccess, error) { + vals := map[string]RemoteLoginPortPublicAccess{ + "disabled": RemoteLoginPortPublicAccessDisabled, + "enabled": RemoteLoginPortPublicAccessEnabled, + "notspecified": RemoteLoginPortPublicAccessNotSpecified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RemoteLoginPortPublicAccess(input) + return &out, nil +} + +type ScheduleProvisioningState string + +const ( + ScheduleProvisioningStateCompleted ScheduleProvisioningState = "Completed" + ScheduleProvisioningStateFailed ScheduleProvisioningState = "Failed" + ScheduleProvisioningStateProvisioning ScheduleProvisioningState = "Provisioning" +) + +func PossibleValuesForScheduleProvisioningState() []string { + return []string{ + string(ScheduleProvisioningStateCompleted), + string(ScheduleProvisioningStateFailed), + string(ScheduleProvisioningStateProvisioning), + } +} + +func (s *ScheduleProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScheduleProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScheduleProvisioningState(input string) (*ScheduleProvisioningState, error) { + vals := map[string]ScheduleProvisioningState{ + "completed": ScheduleProvisioningStateCompleted, + "failed": ScheduleProvisioningStateFailed, + "provisioning": ScheduleProvisioningStateProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScheduleProvisioningState(input) + return &out, nil +} + +type ScheduleStatus string + +const ( + ScheduleStatusDisabled ScheduleStatus = "Disabled" + ScheduleStatusEnabled ScheduleStatus = "Enabled" +) + +func PossibleValuesForScheduleStatus() []string { + return []string{ + string(ScheduleStatusDisabled), + string(ScheduleStatusEnabled), + } +} + +func (s *ScheduleStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScheduleStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScheduleStatus(input string) (*ScheduleStatus, error) { + vals := map[string]ScheduleStatus{ + "disabled": ScheduleStatusDisabled, + "enabled": ScheduleStatusEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScheduleStatus(input) + return &out, nil +} + +type SkuTier string + +const ( + SkuTierBasic SkuTier = "Basic" + SkuTierFree SkuTier = "Free" + SkuTierPremium SkuTier = "Premium" + SkuTierStandard SkuTier = "Standard" +) + +func PossibleValuesForSkuTier() []string { + return []string{ + string(SkuTierBasic), + string(SkuTierFree), + string(SkuTierPremium), + string(SkuTierStandard), + } +} + +func (s *SkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuTier(input string) (*SkuTier, error) { + vals := map[string]SkuTier{ + "basic": SkuTierBasic, + "free": SkuTierFree, + "premium": SkuTierPremium, + "standard": SkuTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuTier(input) + return &out, nil +} + +type SourceType string + +const ( + SourceTypeDataset SourceType = "Dataset" + SourceTypeDatastore SourceType = "Datastore" + SourceTypeURI SourceType = "URI" +) + +func PossibleValuesForSourceType() []string { + return []string{ + string(SourceTypeDataset), + string(SourceTypeDatastore), + string(SourceTypeURI), + } +} + +func (s *SourceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSourceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSourceType(input string) (*SourceType, error) { + vals := map[string]SourceType{ + "dataset": SourceTypeDataset, + "datastore": SourceTypeDatastore, + "uri": SourceTypeURI, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SourceType(input) + return &out, nil +} + +type SshPublicAccess string + +const ( + SshPublicAccessDisabled SshPublicAccess = "Disabled" + SshPublicAccessEnabled SshPublicAccess = "Enabled" +) + +func PossibleValuesForSshPublicAccess() []string { + return []string{ + string(SshPublicAccessDisabled), + string(SshPublicAccessEnabled), + } +} + +func (s *SshPublicAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSshPublicAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSshPublicAccess(input string) (*SshPublicAccess, error) { + vals := map[string]SshPublicAccess{ + "disabled": SshPublicAccessDisabled, + "enabled": SshPublicAccessEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SshPublicAccess(input) + return &out, nil +} + +type SslConfigStatus string + +const ( + SslConfigStatusAuto SslConfigStatus = "Auto" + SslConfigStatusDisabled SslConfigStatus = "Disabled" + SslConfigStatusEnabled SslConfigStatus = "Enabled" +) + +func PossibleValuesForSslConfigStatus() []string { + return []string{ + string(SslConfigStatusAuto), + string(SslConfigStatusDisabled), + string(SslConfigStatusEnabled), + } +} + +func (s *SslConfigStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSslConfigStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSslConfigStatus(input string) (*SslConfigStatus, error) { + vals := map[string]SslConfigStatus{ + "auto": SslConfigStatusAuto, + "disabled": SslConfigStatusDisabled, + "enabled": SslConfigStatusEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SslConfigStatus(input) + return &out, nil +} + +type StorageAccountType string + +const ( + StorageAccountTypePremiumLRS StorageAccountType = "Premium_LRS" + StorageAccountTypeStandardLRS StorageAccountType = "Standard_LRS" +) + +func PossibleValuesForStorageAccountType() []string { + return []string{ + string(StorageAccountTypePremiumLRS), + string(StorageAccountTypeStandardLRS), + } +} + +func (s *StorageAccountType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageAccountType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageAccountType(input string) (*StorageAccountType, error) { + vals := map[string]StorageAccountType{ + "premium_lrs": StorageAccountTypePremiumLRS, + "standard_lrs": StorageAccountTypeStandardLRS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageAccountType(input) + return &out, nil +} + +type UnderlyingResourceAction string + +const ( + UnderlyingResourceActionDelete UnderlyingResourceAction = "Delete" + UnderlyingResourceActionDetach UnderlyingResourceAction = "Detach" +) + +func PossibleValuesForUnderlyingResourceAction() []string { + return []string{ + string(UnderlyingResourceActionDelete), + string(UnderlyingResourceActionDetach), + } +} + +func (s *UnderlyingResourceAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUnderlyingResourceAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUnderlyingResourceAction(input string) (*UnderlyingResourceAction, error) { + vals := map[string]UnderlyingResourceAction{ + "delete": UnderlyingResourceActionDelete, + "detach": UnderlyingResourceActionDetach, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UnderlyingResourceAction(input) + return &out, nil +} + +type VMPriority string + +const ( + VMPriorityDedicated VMPriority = "Dedicated" + VMPriorityLowPriority VMPriority = "LowPriority" +) + +func PossibleValuesForVMPriority() []string { + return []string{ + string(VMPriorityDedicated), + string(VMPriorityLowPriority), + } +} + +func (s *VMPriority) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVMPriority(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVMPriority(input string) (*VMPriority, error) { + vals := map[string]VMPriority{ + "dedicated": VMPriorityDedicated, + "lowpriority": VMPriorityLowPriority, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VMPriority(input) + return &out, nil +} + +type VolumeDefinitionType string + +const ( + VolumeDefinitionTypeBind VolumeDefinitionType = "bind" + VolumeDefinitionTypeNpipe VolumeDefinitionType = "npipe" + VolumeDefinitionTypeTmpfs VolumeDefinitionType = "tmpfs" + VolumeDefinitionTypeVolume VolumeDefinitionType = "volume" +) + +func PossibleValuesForVolumeDefinitionType() []string { + return []string{ + string(VolumeDefinitionTypeBind), + string(VolumeDefinitionTypeNpipe), + string(VolumeDefinitionTypeTmpfs), + string(VolumeDefinitionTypeVolume), + } +} + +func (s *VolumeDefinitionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVolumeDefinitionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVolumeDefinitionType(input string) (*VolumeDefinitionType, error) { + vals := map[string]VolumeDefinitionType{ + "bind": VolumeDefinitionTypeBind, + "npipe": VolumeDefinitionTypeNpipe, + "tmpfs": VolumeDefinitionTypeTmpfs, + "volume": VolumeDefinitionTypeVolume, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VolumeDefinitionType(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/id_compute.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/id_compute.go new file mode 100644 index 00000000000..6c2325adcfd --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/id_compute.go @@ -0,0 +1,139 @@ +package machinelearningcomputes + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ComputeId{}) +} + +var _ resourceids.ResourceId = &ComputeId{} + +// ComputeId is a struct representing the Resource ID for a Compute +type ComputeId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + ComputeName string +} + +// NewComputeID returns a new ComputeId struct +func NewComputeID(subscriptionId string, resourceGroupName string, workspaceName string, computeName string) ComputeId { + return ComputeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + ComputeName: computeName, + } +} + +// ParseComputeID parses 'input' into a ComputeId +func ParseComputeID(input string) (*ComputeId, error) { + parser := resourceids.NewParserFromResourceIdType(&ComputeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ComputeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseComputeIDInsensitively parses 'input' case-insensitively into a ComputeId +// note: this method should only be used for API response data and not user input +func ParseComputeIDInsensitively(input string) (*ComputeId, error) { + parser := resourceids.NewParserFromResourceIdType(&ComputeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ComputeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ComputeId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.ComputeName, ok = input.Parsed["computeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "computeName", input) + } + + return nil +} + +// ValidateComputeID checks that 'input' can be parsed as a Compute ID +func ValidateComputeID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseComputeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Compute ID +func (id ComputeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/computes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.ComputeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Compute ID +func (id ComputeId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticComputes", "computes", "computes"), + resourceids.UserSpecifiedSegment("computeName", "computeName"), + } +} + +// String returns a human-readable description of this Compute ID +func (id ComputeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Compute Name: %q", id.ComputeName), + } + return fmt.Sprintf("Compute (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/id_compute_test.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/id_compute_test.go new file mode 100644 index 00000000000..b381ef6ca0a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/id_compute_test.go @@ -0,0 +1,327 @@ +package machinelearningcomputes + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ComputeId{} + +func TestNewComputeID(t *testing.T) { + id := NewComputeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "computeName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.ComputeName != "computeName" { + t.Fatalf("Expected %q but got %q for Segment 'ComputeName'", id.ComputeName, "computeName") + } +} + +func TestFormatComputeID(t *testing.T) { + actual := NewComputeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "computeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/computes/computeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseComputeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ComputeId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/computes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/computes/computeName", + Expected: &ComputeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + ComputeName: "computeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/computes/computeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseComputeID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.ComputeName != v.Expected.ComputeName { + t.Fatalf("Expected %q but got %q for ComputeName", v.Expected.ComputeName, actual.ComputeName) + } + + } +} + +func TestParseComputeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ComputeId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/computes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOmPuTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/computes/computeName", + Expected: &ComputeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + ComputeName: "computeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/computes/computeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOmPuTeS/cOmPuTeNaMe", + Expected: &ComputeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + ComputeName: "cOmPuTeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOmPuTeS/cOmPuTeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseComputeIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.ComputeName != v.Expected.ComputeName { + t.Fatalf("Expected %q but got %q for ComputeName", v.Expected.ComputeName, actual.ComputeName) + } + + } +} + +func TestSegmentsForComputeId(t *testing.T) { + segments := ComputeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ComputeId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/id_workspace.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/id_workspace.go new file mode 100644 index 00000000000..a0ce39bc1fc --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/id_workspace.go @@ -0,0 +1,130 @@ +package machinelearningcomputes + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/id_workspace_test.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/id_workspace_test.go new file mode 100644 index 00000000000..d9a63643fa4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/id_workspace_test.go @@ -0,0 +1,282 @@ +package machinelearningcomputes + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computecreateorupdate.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computecreateorupdate.go new file mode 100644 index 00000000000..35f4f248616 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computecreateorupdate.go @@ -0,0 +1,75 @@ +package machinelearningcomputes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ComputeResource +} + +// ComputeCreateOrUpdate ... +func (c MachineLearningComputesClient) ComputeCreateOrUpdate(ctx context.Context, id ComputeId, input ComputeResource) (result ComputeCreateOrUpdateOperationResponse, 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 +} + +// ComputeCreateOrUpdateThenPoll performs ComputeCreateOrUpdate then polls until it's completed +func (c MachineLearningComputesClient) ComputeCreateOrUpdateThenPoll(ctx context.Context, id ComputeId, input ComputeResource) error { + result, err := c.ComputeCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ComputeCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ComputeCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computedelete.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computedelete.go new file mode 100644 index 00000000000..bd200979d82 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computedelete.go @@ -0,0 +1,100 @@ +package machinelearningcomputes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type ComputeDeleteOperationOptions struct { + UnderlyingResourceAction *UnderlyingResourceAction +} + +func DefaultComputeDeleteOperationOptions() ComputeDeleteOperationOptions { + return ComputeDeleteOperationOptions{} +} + +func (o ComputeDeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ComputeDeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ComputeDeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.UnderlyingResourceAction != nil { + out.Append("underlyingResourceAction", fmt.Sprintf("%v", *o.UnderlyingResourceAction)) + } + return &out +} + +// ComputeDelete ... +func (c MachineLearningComputesClient) ComputeDelete(ctx context.Context, id ComputeId, options ComputeDeleteOperationOptions) (result ComputeDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ComputeDeleteThenPoll performs ComputeDelete then polls until it's completed +func (c MachineLearningComputesClient) ComputeDeleteThenPoll(ctx context.Context, id ComputeId, options ComputeDeleteOperationOptions) error { + result, err := c.ComputeDelete(ctx, id, options) + if err != nil { + return fmt.Errorf("performing ComputeDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ComputeDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computeget.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computeget.go new file mode 100644 index 00000000000..efcd93aead0 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computeget.go @@ -0,0 +1,53 @@ +package machinelearningcomputes + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ComputeResource +} + +// ComputeGet ... +func (c MachineLearningComputesClient) ComputeGet(ctx context.Context, id ComputeId) (result ComputeGetOperationResponse, 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 ComputeResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computelist.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computelist.go new file mode 100644 index 00000000000..be727b9ad2f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computelist.go @@ -0,0 +1,134 @@ +package machinelearningcomputes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ComputeResource +} + +type ComputeListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ComputeResource +} + +type ComputeListOperationOptions struct { + Skip *string +} + +func DefaultComputeListOperationOptions() ComputeListOperationOptions { + return ComputeListOperationOptions{} +} + +func (o ComputeListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ComputeListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ComputeListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + return &out +} + +type ComputeListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ComputeListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ComputeList ... +func (c MachineLearningComputesClient) ComputeList(ctx context.Context, id WorkspaceId, options ComputeListOperationOptions) (result ComputeListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ComputeListCustomPager{}, + Path: fmt.Sprintf("%s/computes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ComputeResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ComputeListComplete retrieves all the results into a single object +func (c MachineLearningComputesClient) ComputeListComplete(ctx context.Context, id WorkspaceId, options ComputeListOperationOptions) (ComputeListCompleteResult, error) { + return c.ComputeListCompleteMatchingPredicate(ctx, id, options, ComputeResourceOperationPredicate{}) +} + +// ComputeListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MachineLearningComputesClient) ComputeListCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, options ComputeListOperationOptions, predicate ComputeResourceOperationPredicate) (result ComputeListCompleteResult, err error) { + items := make([]ComputeResource, 0) + + resp, err := c.ComputeList(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 = ComputeListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computelistkeys.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computelistkeys.go new file mode 100644 index 00000000000..0ba7e650f66 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computelistkeys.go @@ -0,0 +1,59 @@ +package machinelearningcomputes + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeListKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model ComputeSecrets +} + +// ComputeListKeys ... +func (c MachineLearningComputesClient) ComputeListKeys(ctx context.Context, id ComputeId) (result ComputeListKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var respObj json.RawMessage + if err = resp.Unmarshal(&respObj); err != nil { + return + } + model, err := UnmarshalComputeSecretsImplementation(respObj) + if err != nil { + return + } + result.Model = model + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computelistnodes.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computelistnodes.go new file mode 100644 index 00000000000..720775c6c95 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computelistnodes.go @@ -0,0 +1,105 @@ +package machinelearningcomputes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeListNodesOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AmlComputeNodesInformation +} + +type ComputeListNodesCompleteResult struct { + LatestHttpResponse *http.Response + Items []AmlComputeNodesInformation +} + +type ComputeListNodesCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ComputeListNodesCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ComputeListNodes ... +func (c MachineLearningComputesClient) ComputeListNodes(ctx context.Context, id ComputeId) (result ComputeListNodesOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &ComputeListNodesCustomPager{}, + Path: fmt.Sprintf("%s/listNodes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AmlComputeNodesInformation `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ComputeListNodesComplete retrieves all the results into a single object +func (c MachineLearningComputesClient) ComputeListNodesComplete(ctx context.Context, id ComputeId) (ComputeListNodesCompleteResult, error) { + return c.ComputeListNodesCompleteMatchingPredicate(ctx, id, AmlComputeNodesInformationOperationPredicate{}) +} + +// ComputeListNodesCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MachineLearningComputesClient) ComputeListNodesCompleteMatchingPredicate(ctx context.Context, id ComputeId, predicate AmlComputeNodesInformationOperationPredicate) (result ComputeListNodesCompleteResult, err error) { + items := make([]AmlComputeNodesInformation, 0) + + resp, err := c.ComputeListNodes(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ComputeListNodesCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computerestart.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computerestart.go new file mode 100644 index 00000000000..1c01850d62d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computerestart.go @@ -0,0 +1,69 @@ +package machinelearningcomputes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeRestartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ComputeRestart ... +func (c MachineLearningComputesClient) ComputeRestart(ctx context.Context, id ComputeId) (result ComputeRestartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restart", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ComputeRestartThenPoll performs ComputeRestart then polls until it's completed +func (c MachineLearningComputesClient) ComputeRestartThenPoll(ctx context.Context, id ComputeId) error { + result, err := c.ComputeRestart(ctx, id) + if err != nil { + return fmt.Errorf("performing ComputeRestart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ComputeRestart: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computestart.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computestart.go new file mode 100644 index 00000000000..bae6c8f7575 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computestart.go @@ -0,0 +1,69 @@ +package machinelearningcomputes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeStartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ComputeStart ... +func (c MachineLearningComputesClient) ComputeStart(ctx context.Context, id ComputeId) (result ComputeStartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/start", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ComputeStartThenPoll performs ComputeStart then polls until it's completed +func (c MachineLearningComputesClient) ComputeStartThenPoll(ctx context.Context, id ComputeId) error { + result, err := c.ComputeStart(ctx, id) + if err != nil { + return fmt.Errorf("performing ComputeStart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ComputeStart: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computestop.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computestop.go new file mode 100644 index 00000000000..c37ddfc839b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computestop.go @@ -0,0 +1,69 @@ +package machinelearningcomputes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeStopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ComputeStop ... +func (c MachineLearningComputesClient) ComputeStop(ctx context.Context, id ComputeId) (result ComputeStopOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + 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 +} + +// ComputeStopThenPoll performs ComputeStop then polls until it's completed +func (c MachineLearningComputesClient) ComputeStopThenPoll(ctx context.Context, id ComputeId) error { + result, err := c.ComputeStop(ctx, id) + if err != nil { + return fmt.Errorf("performing ComputeStop: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ComputeStop: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computeupdate.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computeupdate.go new file mode 100644 index 00000000000..e00af1d83af --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/method_computeupdate.go @@ -0,0 +1,74 @@ +package machinelearningcomputes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ComputeResource +} + +// ComputeUpdate ... +func (c MachineLearningComputesClient) ComputeUpdate(ctx context.Context, id ComputeId, input ClusterUpdateParameters) (result ComputeUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ComputeUpdateThenPoll performs ComputeUpdate then polls until it's completed +func (c MachineLearningComputesClient) ComputeUpdateThenPoll(ctx context.Context, id ComputeId, input ClusterUpdateParameters) error { + result, err := c.ComputeUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ComputeUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ComputeUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_aks.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_aks.go new file mode 100644 index 00000000000..47e58464f4c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_aks.go @@ -0,0 +1,95 @@ +package machinelearningcomputes + +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. + +var _ Compute = AKS{} + +type AKS struct { + Properties *AKSSchemaProperties `json:"properties,omitempty"` + + // Fields inherited from Compute + + ComputeLocation *string `json:"computeLocation,omitempty"` + ComputeType ComputeType `json:"computeType"` + CreatedOn *string `json:"createdOn,omitempty"` + Description *string `json:"description,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + IsAttachedCompute *bool `json:"isAttachedCompute,omitempty"` + ModifiedOn *string `json:"modifiedOn,omitempty"` + ProvisioningErrors *[]ErrorResponse `json:"provisioningErrors,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} + +func (s AKS) Compute() BaseComputeImpl { + return BaseComputeImpl{ + ComputeLocation: s.ComputeLocation, + ComputeType: s.ComputeType, + CreatedOn: s.CreatedOn, + Description: s.Description, + DisableLocalAuth: s.DisableLocalAuth, + IsAttachedCompute: s.IsAttachedCompute, + ModifiedOn: s.ModifiedOn, + ProvisioningErrors: s.ProvisioningErrors, + ProvisioningState: s.ProvisioningState, + ResourceId: s.ResourceId, + } +} + +func (o *AKS) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *AKS) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} + +func (o *AKS) GetModifiedOnAsTime() (*time.Time, error) { + if o.ModifiedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *AKS) SetModifiedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedOn = &formatted +} + +var _ json.Marshaler = AKS{} + +func (s AKS) MarshalJSON() ([]byte, error) { + type wrapper AKS + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AKS: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AKS: %+v", err) + } + + decoded["computeType"] = "AKS" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AKS: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_akscomputesecrets.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_akscomputesecrets.go new file mode 100644 index 00000000000..bc1d732f866 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_akscomputesecrets.go @@ -0,0 +1,52 @@ +package machinelearningcomputes + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ComputeSecrets = AksComputeSecrets{} + +type AksComputeSecrets struct { + AdminKubeConfig *string `json:"adminKubeConfig,omitempty"` + ImagePullSecretName *string `json:"imagePullSecretName,omitempty"` + UserKubeConfig *string `json:"userKubeConfig,omitempty"` + + // Fields inherited from ComputeSecrets + + ComputeType ComputeType `json:"computeType"` +} + +func (s AksComputeSecrets) ComputeSecrets() BaseComputeSecretsImpl { + return BaseComputeSecretsImpl{ + ComputeType: s.ComputeType, + } +} + +var _ json.Marshaler = AksComputeSecrets{} + +func (s AksComputeSecrets) MarshalJSON() ([]byte, error) { + type wrapper AksComputeSecrets + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AksComputeSecrets: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AksComputeSecrets: %+v", err) + } + + decoded["computeType"] = "AKS" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AksComputeSecrets: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_aksnetworkingconfiguration.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_aksnetworkingconfiguration.go new file mode 100644 index 00000000000..3cee75f3447 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_aksnetworkingconfiguration.go @@ -0,0 +1,11 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AksNetworkingConfiguration struct { + DnsServiceIP *string `json:"dnsServiceIP,omitempty"` + DockerBridgeCidr *string `json:"dockerBridgeCidr,omitempty"` + ServiceCidr *string `json:"serviceCidr,omitempty"` + SubnetId *string `json:"subnetId,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_aksschemaproperties.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_aksschemaproperties.go new file mode 100644 index 00000000000..b3d32dfef3b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_aksschemaproperties.go @@ -0,0 +1,16 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AKSSchemaProperties struct { + AgentCount *int64 `json:"agentCount,omitempty"` + AgentVMSize *string `json:"agentVmSize,omitempty"` + AksNetworkingConfiguration *AksNetworkingConfiguration `json:"aksNetworkingConfiguration,omitempty"` + ClusterFqdn *string `json:"clusterFqdn,omitempty"` + ClusterPurpose *ClusterPurpose `json:"clusterPurpose,omitempty"` + LoadBalancerSubnet *string `json:"loadBalancerSubnet,omitempty"` + LoadBalancerType *LoadBalancerType `json:"loadBalancerType,omitempty"` + SslConfiguration *SslConfiguration `json:"sslConfiguration,omitempty"` + SystemServices *[]SystemService `json:"systemServices,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_amlcompute.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_amlcompute.go new file mode 100644 index 00000000000..bb3a49f8bdc --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_amlcompute.go @@ -0,0 +1,95 @@ +package machinelearningcomputes + +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. + +var _ Compute = AmlCompute{} + +type AmlCompute struct { + Properties *AmlComputeProperties `json:"properties,omitempty"` + + // Fields inherited from Compute + + ComputeLocation *string `json:"computeLocation,omitempty"` + ComputeType ComputeType `json:"computeType"` + CreatedOn *string `json:"createdOn,omitempty"` + Description *string `json:"description,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + IsAttachedCompute *bool `json:"isAttachedCompute,omitempty"` + ModifiedOn *string `json:"modifiedOn,omitempty"` + ProvisioningErrors *[]ErrorResponse `json:"provisioningErrors,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} + +func (s AmlCompute) Compute() BaseComputeImpl { + return BaseComputeImpl{ + ComputeLocation: s.ComputeLocation, + ComputeType: s.ComputeType, + CreatedOn: s.CreatedOn, + Description: s.Description, + DisableLocalAuth: s.DisableLocalAuth, + IsAttachedCompute: s.IsAttachedCompute, + ModifiedOn: s.ModifiedOn, + ProvisioningErrors: s.ProvisioningErrors, + ProvisioningState: s.ProvisioningState, + ResourceId: s.ResourceId, + } +} + +func (o *AmlCompute) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *AmlCompute) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} + +func (o *AmlCompute) GetModifiedOnAsTime() (*time.Time, error) { + if o.ModifiedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *AmlCompute) SetModifiedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedOn = &formatted +} + +var _ json.Marshaler = AmlCompute{} + +func (s AmlCompute) MarshalJSON() ([]byte, error) { + type wrapper AmlCompute + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AmlCompute: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AmlCompute: %+v", err) + } + + decoded["computeType"] = "AmlCompute" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AmlCompute: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_amlcomputenodeinformation.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_amlcomputenodeinformation.go new file mode 100644 index 00000000000..3a46b521297 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_amlcomputenodeinformation.go @@ -0,0 +1,13 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AmlComputeNodeInformation struct { + NodeId *string `json:"nodeId,omitempty"` + NodeState *NodeState `json:"nodeState,omitempty"` + Port *float64 `json:"port,omitempty"` + PrivateIPAddress *string `json:"privateIpAddress,omitempty"` + PublicIPAddress *string `json:"publicIpAddress,omitempty"` + RunId *string `json:"runId,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_amlcomputenodesinformation.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_amlcomputenodesinformation.go new file mode 100644 index 00000000000..9f6b0b8dbd4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_amlcomputenodesinformation.go @@ -0,0 +1,9 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AmlComputeNodesInformation struct { + NextLink *string `json:"nextLink,omitempty"` + Nodes *[]AmlComputeNodeInformation `json:"nodes,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_amlcomputeproperties.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_amlcomputeproperties.go new file mode 100644 index 00000000000..f287f6a3891 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_amlcomputeproperties.go @@ -0,0 +1,42 @@ +package machinelearningcomputes + +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 AmlComputeProperties struct { + AllocationState *AllocationState `json:"allocationState,omitempty"` + AllocationStateTransitionTime *string `json:"allocationStateTransitionTime,omitempty"` + CurrentNodeCount *int64 `json:"currentNodeCount,omitempty"` + EnableNodePublicIP *bool `json:"enableNodePublicIp,omitempty"` + Errors *[]ErrorResponse `json:"errors,omitempty"` + IsolatedNetwork *bool `json:"isolatedNetwork,omitempty"` + NodeStateCounts *NodeStateCounts `json:"nodeStateCounts,omitempty"` + OsType *OsType `json:"osType,omitempty"` + PropertyBag *interface{} `json:"propertyBag,omitempty"` + RemoteLoginPortPublicAccess *RemoteLoginPortPublicAccess `json:"remoteLoginPortPublicAccess,omitempty"` + ScaleSettings *ScaleSettings `json:"scaleSettings,omitempty"` + Subnet *ResourceId `json:"subnet,omitempty"` + TargetNodeCount *int64 `json:"targetNodeCount,omitempty"` + UserAccountCredentials *UserAccountCredentials `json:"userAccountCredentials,omitempty"` + VMPriority *VMPriority `json:"vmPriority,omitempty"` + VMSize *string `json:"vmSize,omitempty"` + VirtualMachineImage *VirtualMachineImage `json:"virtualMachineImage,omitempty"` +} + +func (o *AmlComputeProperties) GetAllocationStateTransitionTimeAsTime() (*time.Time, error) { + if o.AllocationStateTransitionTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.AllocationStateTransitionTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AmlComputeProperties) SetAllocationStateTransitionTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.AllocationStateTransitionTime = &formatted +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_assigneduser.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_assigneduser.go new file mode 100644 index 00000000000..1cea1e46a43 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_assigneduser.go @@ -0,0 +1,9 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssignedUser struct { + ObjectId string `json:"objectId"` + TenantId string `json:"tenantId"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_autopauseproperties.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_autopauseproperties.go new file mode 100644 index 00000000000..7275a113dc3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_autopauseproperties.go @@ -0,0 +1,9 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoPauseProperties struct { + DelayInMinutes *int64 `json:"delayInMinutes,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_autoscaleproperties.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_autoscaleproperties.go new file mode 100644 index 00000000000..477fb67c36c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_autoscaleproperties.go @@ -0,0 +1,10 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoScaleProperties struct { + Enabled *bool `json:"enabled,omitempty"` + MaxNodeCount *int64 `json:"maxNodeCount,omitempty"` + MinNodeCount *int64 `json:"minNodeCount,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_bindoptions.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_bindoptions.go new file mode 100644 index 00000000000..e63e17cb6cf --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_bindoptions.go @@ -0,0 +1,10 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BindOptions struct { + CreateHostPath *bool `json:"createHostPath,omitempty"` + Propagation *string `json:"propagation,omitempty"` + Selinux *string `json:"selinux,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_clusterupdateparameters.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_clusterupdateparameters.go new file mode 100644 index 00000000000..409c14c3c9e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_clusterupdateparameters.go @@ -0,0 +1,8 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterUpdateParameters struct { + Properties *ClusterUpdateProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_clusterupdateproperties.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_clusterupdateproperties.go new file mode 100644 index 00000000000..734e2b1dcf6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_clusterupdateproperties.go @@ -0,0 +1,8 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterUpdateProperties struct { + Properties *ScaleSettingsInformation `json:"properties,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_compute.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_compute.go new file mode 100644 index 00000000000..66bea557177 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_compute.go @@ -0,0 +1,156 @@ +package machinelearningcomputes + +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 Compute interface { + Compute() BaseComputeImpl +} + +var _ Compute = BaseComputeImpl{} + +type BaseComputeImpl struct { + ComputeLocation *string `json:"computeLocation,omitempty"` + ComputeType ComputeType `json:"computeType"` + CreatedOn *string `json:"createdOn,omitempty"` + Description *string `json:"description,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + IsAttachedCompute *bool `json:"isAttachedCompute,omitempty"` + ModifiedOn *string `json:"modifiedOn,omitempty"` + ProvisioningErrors *[]ErrorResponse `json:"provisioningErrors,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} + +func (s BaseComputeImpl) Compute() BaseComputeImpl { + return s +} + +var _ Compute = RawComputeImpl{} + +// RawComputeImpl 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 RawComputeImpl struct { + compute BaseComputeImpl + Type string + Values map[string]interface{} +} + +func (s RawComputeImpl) Compute() BaseComputeImpl { + return s.compute +} + +func UnmarshalComputeImplementation(input []byte) (Compute, 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 Compute into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["computeType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AKS") { + var out AKS + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AKS: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AmlCompute") { + var out AmlCompute + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AmlCompute: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ComputeInstance") { + var out ComputeInstance + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ComputeInstance: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DataFactory") { + var out DataFactory + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DataFactory: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DataLakeAnalytics") { + var out DataLakeAnalytics + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DataLakeAnalytics: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Databricks") { + var out Databricks + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into Databricks: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HDInsight") { + var out HDInsight + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HDInsight: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Kubernetes") { + var out Kubernetes + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into Kubernetes: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SynapseSpark") { + var out SynapseSpark + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SynapseSpark: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VirtualMachine") { + var out VirtualMachine + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VirtualMachine: %+v", err) + } + return out, nil + } + + var parent BaseComputeImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseComputeImpl: %+v", err) + } + + return RawComputeImpl{ + compute: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstance.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstance.go new file mode 100644 index 00000000000..10054583862 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstance.go @@ -0,0 +1,95 @@ +package machinelearningcomputes + +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. + +var _ Compute = ComputeInstance{} + +type ComputeInstance struct { + Properties *ComputeInstanceProperties `json:"properties,omitempty"` + + // Fields inherited from Compute + + ComputeLocation *string `json:"computeLocation,omitempty"` + ComputeType ComputeType `json:"computeType"` + CreatedOn *string `json:"createdOn,omitempty"` + Description *string `json:"description,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + IsAttachedCompute *bool `json:"isAttachedCompute,omitempty"` + ModifiedOn *string `json:"modifiedOn,omitempty"` + ProvisioningErrors *[]ErrorResponse `json:"provisioningErrors,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} + +func (s ComputeInstance) Compute() BaseComputeImpl { + return BaseComputeImpl{ + ComputeLocation: s.ComputeLocation, + ComputeType: s.ComputeType, + CreatedOn: s.CreatedOn, + Description: s.Description, + DisableLocalAuth: s.DisableLocalAuth, + IsAttachedCompute: s.IsAttachedCompute, + ModifiedOn: s.ModifiedOn, + ProvisioningErrors: s.ProvisioningErrors, + ProvisioningState: s.ProvisioningState, + ResourceId: s.ResourceId, + } +} + +func (o *ComputeInstance) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *ComputeInstance) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} + +func (o *ComputeInstance) GetModifiedOnAsTime() (*time.Time, error) { + if o.ModifiedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *ComputeInstance) SetModifiedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedOn = &formatted +} + +var _ json.Marshaler = ComputeInstance{} + +func (s ComputeInstance) MarshalJSON() ([]byte, error) { + type wrapper ComputeInstance + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ComputeInstance: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ComputeInstance: %+v", err) + } + + decoded["computeType"] = "ComputeInstance" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ComputeInstance: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstanceapplication.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstanceapplication.go new file mode 100644 index 00000000000..29069347cc2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstanceapplication.go @@ -0,0 +1,9 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeInstanceApplication struct { + DisplayName *string `json:"displayName,omitempty"` + EndpointUri *string `json:"endpointUri,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstanceconnectivityendpoints.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstanceconnectivityendpoints.go new file mode 100644 index 00000000000..806067ce626 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstanceconnectivityendpoints.go @@ -0,0 +1,9 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeInstanceConnectivityEndpoints struct { + PrivateIPAddress *string `json:"privateIpAddress,omitempty"` + PublicIPAddress *string `json:"publicIpAddress,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstancecontainer.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstancecontainer.go new file mode 100644 index 00000000000..e21fffac904 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstancecontainer.go @@ -0,0 +1,13 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeInstanceContainer struct { + Autosave *Autosave `json:"autosave,omitempty"` + Environment *ComputeInstanceEnvironmentInfo `json:"environment,omitempty"` + Gpu *string `json:"gpu,omitempty"` + Name *string `json:"name,omitempty"` + Network *Network `json:"network,omitempty"` + Services *[]interface{} `json:"services,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstancecreatedby.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstancecreatedby.go new file mode 100644 index 00000000000..8badc26c3a4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstancecreatedby.go @@ -0,0 +1,10 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeInstanceCreatedBy struct { + UserId *string `json:"userId,omitempty"` + UserName *string `json:"userName,omitempty"` + UserOrgId *string `json:"userOrgId,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstancedatadisk.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstancedatadisk.go new file mode 100644 index 00000000000..f7f2bb4a623 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstancedatadisk.go @@ -0,0 +1,11 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeInstanceDataDisk struct { + Caching *Caching `json:"caching,omitempty"` + DiskSizeGB *int64 `json:"diskSizeGB,omitempty"` + Lun *int64 `json:"lun,omitempty"` + StorageAccountType *StorageAccountType `json:"storageAccountType,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstancedatamount.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstancedatamount.go new file mode 100644 index 00000000000..9da0d27488f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstancedatamount.go @@ -0,0 +1,34 @@ +package machinelearningcomputes + +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 ComputeInstanceDataMount struct { + CreatedBy *string `json:"createdBy,omitempty"` + Error *string `json:"error,omitempty"` + MountAction *MountAction `json:"mountAction,omitempty"` + MountName *string `json:"mountName,omitempty"` + MountPath *string `json:"mountPath,omitempty"` + MountState *MountState `json:"mountState,omitempty"` + MountedOn *string `json:"mountedOn,omitempty"` + Source *string `json:"source,omitempty"` + SourceType *SourceType `json:"sourceType,omitempty"` +} + +func (o *ComputeInstanceDataMount) GetMountedOnAsTime() (*time.Time, error) { + if o.MountedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.MountedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *ComputeInstanceDataMount) SetMountedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.MountedOn = &formatted +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstanceenvironmentinfo.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstanceenvironmentinfo.go new file mode 100644 index 00000000000..7b87a09917b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstanceenvironmentinfo.go @@ -0,0 +1,9 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeInstanceEnvironmentInfo struct { + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstancelastoperation.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstancelastoperation.go new file mode 100644 index 00000000000..6f2a4107583 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstancelastoperation.go @@ -0,0 +1,29 @@ +package machinelearningcomputes + +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 ComputeInstanceLastOperation struct { + OperationName *OperationName `json:"operationName,omitempty"` + OperationStatus *OperationStatus `json:"operationStatus,omitempty"` + OperationTime *string `json:"operationTime,omitempty"` + OperationTrigger *OperationTrigger `json:"operationTrigger,omitempty"` +} + +func (o *ComputeInstanceLastOperation) GetOperationTimeAsTime() (*time.Time, error) { + if o.OperationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OperationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ComputeInstanceLastOperation) SetOperationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OperationTime = &formatted +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstanceproperties.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstanceproperties.go new file mode 100644 index 00000000000..e55301a963b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstanceproperties.go @@ -0,0 +1,28 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeInstanceProperties struct { + ApplicationSharingPolicy *ApplicationSharingPolicy `json:"applicationSharingPolicy,omitempty"` + Applications *[]ComputeInstanceApplication `json:"applications,omitempty"` + ComputeInstanceAuthorizationType *ComputeInstanceAuthorizationType `json:"computeInstanceAuthorizationType,omitempty"` + ConnectivityEndpoints *ComputeInstanceConnectivityEndpoints `json:"connectivityEndpoints,omitempty"` + Containers *[]ComputeInstanceContainer `json:"containers,omitempty"` + CreatedBy *ComputeInstanceCreatedBy `json:"createdBy,omitempty"` + CustomServices *[]CustomService `json:"customServices,omitempty"` + DataDisks *[]ComputeInstanceDataDisk `json:"dataDisks,omitempty"` + DataMounts *[]ComputeInstanceDataMount `json:"dataMounts,omitempty"` + EnableNodePublicIP *bool `json:"enableNodePublicIp,omitempty"` + Errors *[]ErrorResponse `json:"errors,omitempty"` + LastOperation *ComputeInstanceLastOperation `json:"lastOperation,omitempty"` + OsImageMetadata *ImageMetadata `json:"osImageMetadata,omitempty"` + PersonalComputeInstanceSettings *PersonalComputeInstanceSettings `json:"personalComputeInstanceSettings,omitempty"` + Schedules *ComputeSchedules `json:"schedules,omitempty"` + SetupScripts *SetupScripts `json:"setupScripts,omitempty"` + SshSettings *ComputeInstanceSshSettings `json:"sshSettings,omitempty"` + State *ComputeInstanceState `json:"state,omitempty"` + Subnet *ResourceId `json:"subnet,omitempty"` + VMSize *string `json:"vmSize,omitempty"` + Versions *ComputeInstanceVersion `json:"versions,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstancesshsettings.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstancesshsettings.go new file mode 100644 index 00000000000..2afa3fea0cb --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstancesshsettings.go @@ -0,0 +1,11 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeInstanceSshSettings struct { + AdminPublicKey *string `json:"adminPublicKey,omitempty"` + AdminUserName *string `json:"adminUserName,omitempty"` + SshPort *int64 `json:"sshPort,omitempty"` + SshPublicAccess *SshPublicAccess `json:"sshPublicAccess,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstanceversion.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstanceversion.go new file mode 100644 index 00000000000..f197ea76f1e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeinstanceversion.go @@ -0,0 +1,8 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeInstanceVersion struct { + Runtime *string `json:"runtime,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computerecurrenceschedule.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computerecurrenceschedule.go new file mode 100644 index 00000000000..902b4b1542b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computerecurrenceschedule.go @@ -0,0 +1,11 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeRecurrenceSchedule struct { + Hours []int64 `json:"hours"` + Minutes []int64 `json:"minutes"` + MonthDays *[]int64 `json:"monthDays,omitempty"` + WeekDays *[]ComputeWeekDay `json:"weekDays,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeresource.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeresource.go new file mode 100644 index 00000000000..83405c3405a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeresource.go @@ -0,0 +1,66 @@ +package machinelearningcomputes + +import ( + "encoding/json" + "fmt" + + "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 ComputeResource struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties Compute `json:"properties"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ComputeResource{} + +func (s *ComputeResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Id = decoded.Id + s.Identity = decoded.Identity + s.Location = decoded.Location + s.Name = decoded.Name + s.Sku = decoded.Sku + s.SystemData = decoded.SystemData + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ComputeResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalComputeImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ComputeResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeschedules.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeschedules.go new file mode 100644 index 00000000000..d30d36696b8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computeschedules.go @@ -0,0 +1,8 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeSchedules struct { + ComputeStartStop *[]ComputeStartStopSchedule `json:"computeStartStop,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computesecrets.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computesecrets.go new file mode 100644 index 00000000000..411d4b970b8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computesecrets.go @@ -0,0 +1,91 @@ +package machinelearningcomputes + +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 ComputeSecrets interface { + ComputeSecrets() BaseComputeSecretsImpl +} + +var _ ComputeSecrets = BaseComputeSecretsImpl{} + +type BaseComputeSecretsImpl struct { + ComputeType ComputeType `json:"computeType"` +} + +func (s BaseComputeSecretsImpl) ComputeSecrets() BaseComputeSecretsImpl { + return s +} + +var _ ComputeSecrets = RawComputeSecretsImpl{} + +// RawComputeSecretsImpl 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 RawComputeSecretsImpl struct { + computeSecrets BaseComputeSecretsImpl + Type string + Values map[string]interface{} +} + +func (s RawComputeSecretsImpl) ComputeSecrets() BaseComputeSecretsImpl { + return s.computeSecrets +} + +func UnmarshalComputeSecretsImplementation(input []byte) (ComputeSecrets, 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 ComputeSecrets into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["computeType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AKS") { + var out AksComputeSecrets + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AksComputeSecrets: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Databricks") { + var out DatabricksComputeSecrets + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DatabricksComputeSecrets: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VirtualMachine") { + var out VirtualMachineSecrets + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VirtualMachineSecrets: %+v", err) + } + return out, nil + } + + var parent BaseComputeSecretsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseComputeSecretsImpl: %+v", err) + } + + return RawComputeSecretsImpl{ + computeSecrets: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computestartstopschedule.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computestartstopschedule.go new file mode 100644 index 00000000000..ee68535424f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_computestartstopschedule.go @@ -0,0 +1,15 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeStartStopSchedule struct { + Action *ComputePowerAction `json:"action,omitempty"` + Cron *Cron `json:"cron,omitempty"` + Id *string `json:"id,omitempty"` + ProvisioningStatus *ProvisioningStatus `json:"provisioningStatus,omitempty"` + Recurrence *Recurrence `json:"recurrence,omitempty"` + Schedule *ScheduleBase `json:"schedule,omitempty"` + Status *ScheduleStatus `json:"status,omitempty"` + TriggerType *ComputeTriggerType `json:"triggerType,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_cron.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_cron.go new file mode 100644 index 00000000000..60df0729aaa --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_cron.go @@ -0,0 +1,10 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Cron struct { + Expression *string `json:"expression,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_customservice.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_customservice.go new file mode 100644 index 00000000000..100972ee309 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_customservice.go @@ -0,0 +1,13 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomService struct { + Docker *Docker `json:"docker,omitempty"` + Endpoints *[]Endpoint `json:"endpoints,omitempty"` + EnvironmentVariables *map[string]EnvironmentVariable `json:"environmentVariables,omitempty"` + Image *Image `json:"image,omitempty"` + Name *string `json:"name,omitempty"` + Volumes *[]VolumeDefinition `json:"volumes,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_databricks.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_databricks.go new file mode 100644 index 00000000000..6ead8d21e03 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_databricks.go @@ -0,0 +1,95 @@ +package machinelearningcomputes + +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. + +var _ Compute = Databricks{} + +type Databricks struct { + Properties *DatabricksProperties `json:"properties,omitempty"` + + // Fields inherited from Compute + + ComputeLocation *string `json:"computeLocation,omitempty"` + ComputeType ComputeType `json:"computeType"` + CreatedOn *string `json:"createdOn,omitempty"` + Description *string `json:"description,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + IsAttachedCompute *bool `json:"isAttachedCompute,omitempty"` + ModifiedOn *string `json:"modifiedOn,omitempty"` + ProvisioningErrors *[]ErrorResponse `json:"provisioningErrors,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} + +func (s Databricks) Compute() BaseComputeImpl { + return BaseComputeImpl{ + ComputeLocation: s.ComputeLocation, + ComputeType: s.ComputeType, + CreatedOn: s.CreatedOn, + Description: s.Description, + DisableLocalAuth: s.DisableLocalAuth, + IsAttachedCompute: s.IsAttachedCompute, + ModifiedOn: s.ModifiedOn, + ProvisioningErrors: s.ProvisioningErrors, + ProvisioningState: s.ProvisioningState, + ResourceId: s.ResourceId, + } +} + +func (o *Databricks) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *Databricks) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} + +func (o *Databricks) GetModifiedOnAsTime() (*time.Time, error) { + if o.ModifiedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *Databricks) SetModifiedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedOn = &formatted +} + +var _ json.Marshaler = Databricks{} + +func (s Databricks) MarshalJSON() ([]byte, error) { + type wrapper Databricks + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling Databricks: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling Databricks: %+v", err) + } + + decoded["computeType"] = "Databricks" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling Databricks: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_databrickscomputesecrets.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_databrickscomputesecrets.go new file mode 100644 index 00000000000..c076e457360 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_databrickscomputesecrets.go @@ -0,0 +1,50 @@ +package machinelearningcomputes + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ComputeSecrets = DatabricksComputeSecrets{} + +type DatabricksComputeSecrets struct { + DatabricksAccessToken *string `json:"databricksAccessToken,omitempty"` + + // Fields inherited from ComputeSecrets + + ComputeType ComputeType `json:"computeType"` +} + +func (s DatabricksComputeSecrets) ComputeSecrets() BaseComputeSecretsImpl { + return BaseComputeSecretsImpl{ + ComputeType: s.ComputeType, + } +} + +var _ json.Marshaler = DatabricksComputeSecrets{} + +func (s DatabricksComputeSecrets) MarshalJSON() ([]byte, error) { + type wrapper DatabricksComputeSecrets + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DatabricksComputeSecrets: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DatabricksComputeSecrets: %+v", err) + } + + decoded["computeType"] = "Databricks" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DatabricksComputeSecrets: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_databricksproperties.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_databricksproperties.go new file mode 100644 index 00000000000..20bf4a99606 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_databricksproperties.go @@ -0,0 +1,9 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabricksProperties struct { + DatabricksAccessToken *string `json:"databricksAccessToken,omitempty"` + WorkspaceURL *string `json:"workspaceUrl,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_datafactory.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_datafactory.go new file mode 100644 index 00000000000..bd37468d428 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_datafactory.go @@ -0,0 +1,94 @@ +package machinelearningcomputes + +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. + +var _ Compute = DataFactory{} + +type DataFactory struct { + + // Fields inherited from Compute + + ComputeLocation *string `json:"computeLocation,omitempty"` + ComputeType ComputeType `json:"computeType"` + CreatedOn *string `json:"createdOn,omitempty"` + Description *string `json:"description,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + IsAttachedCompute *bool `json:"isAttachedCompute,omitempty"` + ModifiedOn *string `json:"modifiedOn,omitempty"` + ProvisioningErrors *[]ErrorResponse `json:"provisioningErrors,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} + +func (s DataFactory) Compute() BaseComputeImpl { + return BaseComputeImpl{ + ComputeLocation: s.ComputeLocation, + ComputeType: s.ComputeType, + CreatedOn: s.CreatedOn, + Description: s.Description, + DisableLocalAuth: s.DisableLocalAuth, + IsAttachedCompute: s.IsAttachedCompute, + ModifiedOn: s.ModifiedOn, + ProvisioningErrors: s.ProvisioningErrors, + ProvisioningState: s.ProvisioningState, + ResourceId: s.ResourceId, + } +} + +func (o *DataFactory) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *DataFactory) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} + +func (o *DataFactory) GetModifiedOnAsTime() (*time.Time, error) { + if o.ModifiedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *DataFactory) SetModifiedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedOn = &formatted +} + +var _ json.Marshaler = DataFactory{} + +func (s DataFactory) MarshalJSON() ([]byte, error) { + type wrapper DataFactory + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DataFactory: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DataFactory: %+v", err) + } + + decoded["computeType"] = "DataFactory" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DataFactory: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_datalakeanalytics.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_datalakeanalytics.go new file mode 100644 index 00000000000..9c304ddb04e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_datalakeanalytics.go @@ -0,0 +1,95 @@ +package machinelearningcomputes + +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. + +var _ Compute = DataLakeAnalytics{} + +type DataLakeAnalytics struct { + Properties *DataLakeAnalyticsSchemaProperties `json:"properties,omitempty"` + + // Fields inherited from Compute + + ComputeLocation *string `json:"computeLocation,omitempty"` + ComputeType ComputeType `json:"computeType"` + CreatedOn *string `json:"createdOn,omitempty"` + Description *string `json:"description,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + IsAttachedCompute *bool `json:"isAttachedCompute,omitempty"` + ModifiedOn *string `json:"modifiedOn,omitempty"` + ProvisioningErrors *[]ErrorResponse `json:"provisioningErrors,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} + +func (s DataLakeAnalytics) Compute() BaseComputeImpl { + return BaseComputeImpl{ + ComputeLocation: s.ComputeLocation, + ComputeType: s.ComputeType, + CreatedOn: s.CreatedOn, + Description: s.Description, + DisableLocalAuth: s.DisableLocalAuth, + IsAttachedCompute: s.IsAttachedCompute, + ModifiedOn: s.ModifiedOn, + ProvisioningErrors: s.ProvisioningErrors, + ProvisioningState: s.ProvisioningState, + ResourceId: s.ResourceId, + } +} + +func (o *DataLakeAnalytics) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *DataLakeAnalytics) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} + +func (o *DataLakeAnalytics) GetModifiedOnAsTime() (*time.Time, error) { + if o.ModifiedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *DataLakeAnalytics) SetModifiedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedOn = &formatted +} + +var _ json.Marshaler = DataLakeAnalytics{} + +func (s DataLakeAnalytics) MarshalJSON() ([]byte, error) { + type wrapper DataLakeAnalytics + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DataLakeAnalytics: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DataLakeAnalytics: %+v", err) + } + + decoded["computeType"] = "DataLakeAnalytics" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DataLakeAnalytics: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_datalakeanalyticsschemaproperties.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_datalakeanalyticsschemaproperties.go new file mode 100644 index 00000000000..18acd597a1b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_datalakeanalyticsschemaproperties.go @@ -0,0 +1,8 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataLakeAnalyticsSchemaProperties struct { + DataLakeStoreAccountName *string `json:"dataLakeStoreAccountName,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_docker.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_docker.go new file mode 100644 index 00000000000..6ecb3405434 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_docker.go @@ -0,0 +1,8 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Docker struct { + Privileged *bool `json:"privileged,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_endpoint.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_endpoint.go new file mode 100644 index 00000000000..7174d604913 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_endpoint.go @@ -0,0 +1,12 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Endpoint struct { + HostIP *string `json:"hostIp,omitempty"` + Name *string `json:"name,omitempty"` + Protocol *Protocol `json:"protocol,omitempty"` + Published *int64 `json:"published,omitempty"` + Target *int64 `json:"target,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_environmentvariable.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_environmentvariable.go new file mode 100644 index 00000000000..cb8a867804e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_environmentvariable.go @@ -0,0 +1,9 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnvironmentVariable struct { + Type *EnvironmentVariableType `json:"type,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_erroradditionalinfo.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_erroradditionalinfo.go new file mode 100644 index 00000000000..c8bfdef6877 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_erroradditionalinfo.go @@ -0,0 +1,9 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorAdditionalInfo struct { + Info *interface{} `json:"info,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_errordetail.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_errordetail.go new file mode 100644 index 00000000000..c517f46aee8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_errordetail.go @@ -0,0 +1,12 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + Details *[]ErrorDetail `json:"details,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_errorresponse.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_errorresponse.go new file mode 100644 index 00000000000..4d4b4e9be54 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_errorresponse.go @@ -0,0 +1,8 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorResponse struct { + Error *ErrorDetail `json:"error,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_hdinsight.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_hdinsight.go new file mode 100644 index 00000000000..4e043b808fb --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_hdinsight.go @@ -0,0 +1,95 @@ +package machinelearningcomputes + +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. + +var _ Compute = HDInsight{} + +type HDInsight struct { + Properties *HDInsightProperties `json:"properties,omitempty"` + + // Fields inherited from Compute + + ComputeLocation *string `json:"computeLocation,omitempty"` + ComputeType ComputeType `json:"computeType"` + CreatedOn *string `json:"createdOn,omitempty"` + Description *string `json:"description,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + IsAttachedCompute *bool `json:"isAttachedCompute,omitempty"` + ModifiedOn *string `json:"modifiedOn,omitempty"` + ProvisioningErrors *[]ErrorResponse `json:"provisioningErrors,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} + +func (s HDInsight) Compute() BaseComputeImpl { + return BaseComputeImpl{ + ComputeLocation: s.ComputeLocation, + ComputeType: s.ComputeType, + CreatedOn: s.CreatedOn, + Description: s.Description, + DisableLocalAuth: s.DisableLocalAuth, + IsAttachedCompute: s.IsAttachedCompute, + ModifiedOn: s.ModifiedOn, + ProvisioningErrors: s.ProvisioningErrors, + ProvisioningState: s.ProvisioningState, + ResourceId: s.ResourceId, + } +} + +func (o *HDInsight) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *HDInsight) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} + +func (o *HDInsight) GetModifiedOnAsTime() (*time.Time, error) { + if o.ModifiedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *HDInsight) SetModifiedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedOn = &formatted +} + +var _ json.Marshaler = HDInsight{} + +func (s HDInsight) MarshalJSON() ([]byte, error) { + type wrapper HDInsight + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HDInsight: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HDInsight: %+v", err) + } + + decoded["computeType"] = "HDInsight" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HDInsight: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_hdinsightproperties.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_hdinsightproperties.go new file mode 100644 index 00000000000..ae520cc46e8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_hdinsightproperties.go @@ -0,0 +1,10 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HDInsightProperties struct { + Address *string `json:"address,omitempty"` + AdministratorAccount *VirtualMachineSshCredentials `json:"administratorAccount,omitempty"` + SshPort *int64 `json:"sshPort,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_image.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_image.go new file mode 100644 index 00000000000..dfe9786318f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_image.go @@ -0,0 +1,9 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Image struct { + Reference *string `json:"reference,omitempty"` + Type *ImageType `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_imagemetadata.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_imagemetadata.go new file mode 100644 index 00000000000..53f0d01dbba --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_imagemetadata.go @@ -0,0 +1,10 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImageMetadata struct { + CurrentImageVersion *string `json:"currentImageVersion,omitempty"` + IsLatestOsImageVersion *bool `json:"isLatestOsImageVersion,omitempty"` + LatestImageVersion *string `json:"latestImageVersion,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_instancetypeschema.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_instancetypeschema.go new file mode 100644 index 00000000000..3d54d19ad88 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_instancetypeschema.go @@ -0,0 +1,9 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InstanceTypeSchema struct { + NodeSelector *map[string]string `json:"nodeSelector,omitempty"` + Resources *InstanceTypeSchemaResources `json:"resources,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_instancetypeschemaresources.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_instancetypeschemaresources.go new file mode 100644 index 00000000000..436be5b4091 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_instancetypeschemaresources.go @@ -0,0 +1,9 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InstanceTypeSchemaResources struct { + Limits *map[string]string `json:"limits,omitempty"` + Requests *map[string]string `json:"requests,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_kubernetes.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_kubernetes.go new file mode 100644 index 00000000000..f74ac98dbde --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_kubernetes.go @@ -0,0 +1,95 @@ +package machinelearningcomputes + +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. + +var _ Compute = Kubernetes{} + +type Kubernetes struct { + Properties *KubernetesProperties `json:"properties,omitempty"` + + // Fields inherited from Compute + + ComputeLocation *string `json:"computeLocation,omitempty"` + ComputeType ComputeType `json:"computeType"` + CreatedOn *string `json:"createdOn,omitempty"` + Description *string `json:"description,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + IsAttachedCompute *bool `json:"isAttachedCompute,omitempty"` + ModifiedOn *string `json:"modifiedOn,omitempty"` + ProvisioningErrors *[]ErrorResponse `json:"provisioningErrors,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} + +func (s Kubernetes) Compute() BaseComputeImpl { + return BaseComputeImpl{ + ComputeLocation: s.ComputeLocation, + ComputeType: s.ComputeType, + CreatedOn: s.CreatedOn, + Description: s.Description, + DisableLocalAuth: s.DisableLocalAuth, + IsAttachedCompute: s.IsAttachedCompute, + ModifiedOn: s.ModifiedOn, + ProvisioningErrors: s.ProvisioningErrors, + ProvisioningState: s.ProvisioningState, + ResourceId: s.ResourceId, + } +} + +func (o *Kubernetes) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *Kubernetes) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} + +func (o *Kubernetes) GetModifiedOnAsTime() (*time.Time, error) { + if o.ModifiedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *Kubernetes) SetModifiedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedOn = &formatted +} + +var _ json.Marshaler = Kubernetes{} + +func (s Kubernetes) MarshalJSON() ([]byte, error) { + type wrapper Kubernetes + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling Kubernetes: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling Kubernetes: %+v", err) + } + + decoded["computeType"] = "Kubernetes" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling Kubernetes: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_kubernetesproperties.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_kubernetesproperties.go new file mode 100644 index 00000000000..2c027ee1f07 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_kubernetesproperties.go @@ -0,0 +1,15 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubernetesProperties struct { + DefaultInstanceType *string `json:"defaultInstanceType,omitempty"` + ExtensionInstanceReleaseTrain *string `json:"extensionInstanceReleaseTrain,omitempty"` + ExtensionPrincipalId *string `json:"extensionPrincipalId,omitempty"` + InstanceTypes *map[string]InstanceTypeSchema `json:"instanceTypes,omitempty"` + Namespace *string `json:"namespace,omitempty"` + RelayConnectionString *string `json:"relayConnectionString,omitempty"` + ServiceBusConnectionString *string `json:"serviceBusConnectionString,omitempty"` + VcName *string `json:"vcName,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_nodestatecounts.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_nodestatecounts.go new file mode 100644 index 00000000000..b52b2988fe3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_nodestatecounts.go @@ -0,0 +1,13 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NodeStateCounts struct { + IdleNodeCount *int64 `json:"idleNodeCount,omitempty"` + LeavingNodeCount *int64 `json:"leavingNodeCount,omitempty"` + PreemptedNodeCount *int64 `json:"preemptedNodeCount,omitempty"` + PreparingNodeCount *int64 `json:"preparingNodeCount,omitempty"` + RunningNodeCount *int64 `json:"runningNodeCount,omitempty"` + UnusableNodeCount *int64 `json:"unusableNodeCount,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_personalcomputeinstancesettings.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_personalcomputeinstancesettings.go new file mode 100644 index 00000000000..684e03b3706 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_personalcomputeinstancesettings.go @@ -0,0 +1,8 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PersonalComputeInstanceSettings struct { + AssignedUser *AssignedUser `json:"assignedUser,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_recurrence.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_recurrence.go new file mode 100644 index 00000000000..c7765b01191 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_recurrence.go @@ -0,0 +1,12 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Recurrence struct { + Frequency *ComputeRecurrenceFrequency `json:"frequency,omitempty"` + Interval *int64 `json:"interval,omitempty"` + Schedule *ComputeRecurrenceSchedule `json:"schedule,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_resourceid.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_resourceid.go new file mode 100644 index 00000000000..f4a566848d2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_resourceid.go @@ -0,0 +1,8 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_scalesettings.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_scalesettings.go new file mode 100644 index 00000000000..1ca12f87d34 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_scalesettings.go @@ -0,0 +1,10 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScaleSettings struct { + MaxNodeCount int64 `json:"maxNodeCount"` + MinNodeCount *int64 `json:"minNodeCount,omitempty"` + NodeIdleTimeBeforeScaleDown *string `json:"nodeIdleTimeBeforeScaleDown,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_scalesettingsinformation.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_scalesettingsinformation.go new file mode 100644 index 00000000000..779e0d1092e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_scalesettingsinformation.go @@ -0,0 +1,8 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScaleSettingsInformation struct { + ScaleSettings *ScaleSettings `json:"scaleSettings,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_schedulebase.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_schedulebase.go new file mode 100644 index 00000000000..be4a7bf9c5a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_schedulebase.go @@ -0,0 +1,10 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScheduleBase struct { + Id *string `json:"id,omitempty"` + ProvisioningStatus *ScheduleProvisioningState `json:"provisioningStatus,omitempty"` + Status *ScheduleStatus `json:"status,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_scriptreference.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_scriptreference.go new file mode 100644 index 00000000000..521b2271159 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_scriptreference.go @@ -0,0 +1,11 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScriptReference struct { + ScriptArguments *string `json:"scriptArguments,omitempty"` + ScriptData *string `json:"scriptData,omitempty"` + ScriptSource *string `json:"scriptSource,omitempty"` + Timeout *string `json:"timeout,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_scriptstoexecute.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_scriptstoexecute.go new file mode 100644 index 00000000000..71c845ef62f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_scriptstoexecute.go @@ -0,0 +1,9 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScriptsToExecute struct { + CreationScript *ScriptReference `json:"creationScript,omitempty"` + StartupScript *ScriptReference `json:"startupScript,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_setupscripts.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_setupscripts.go new file mode 100644 index 00000000000..9a08bcab361 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_setupscripts.go @@ -0,0 +1,8 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SetupScripts struct { + Scripts *ScriptsToExecute `json:"scripts,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_sku.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_sku.go new file mode 100644 index 00000000000..8e5c1cdb912 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_sku.go @@ -0,0 +1,12 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Name string `json:"name"` + Size *string `json:"size,omitempty"` + Tier *SkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_sslconfiguration.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_sslconfiguration.go new file mode 100644 index 00000000000..71a4753d55d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_sslconfiguration.go @@ -0,0 +1,13 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SslConfiguration struct { + Cert *string `json:"cert,omitempty"` + Cname *string `json:"cname,omitempty"` + Key *string `json:"key,omitempty"` + LeafDomainLabel *string `json:"leafDomainLabel,omitempty"` + OverwriteExistingDomain *bool `json:"overwriteExistingDomain,omitempty"` + Status *SslConfigStatus `json:"status,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_synapsespark.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_synapsespark.go new file mode 100644 index 00000000000..54cc3af0202 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_synapsespark.go @@ -0,0 +1,95 @@ +package machinelearningcomputes + +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. + +var _ Compute = SynapseSpark{} + +type SynapseSpark struct { + Properties *SynapseSparkProperties `json:"properties,omitempty"` + + // Fields inherited from Compute + + ComputeLocation *string `json:"computeLocation,omitempty"` + ComputeType ComputeType `json:"computeType"` + CreatedOn *string `json:"createdOn,omitempty"` + Description *string `json:"description,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + IsAttachedCompute *bool `json:"isAttachedCompute,omitempty"` + ModifiedOn *string `json:"modifiedOn,omitempty"` + ProvisioningErrors *[]ErrorResponse `json:"provisioningErrors,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} + +func (s SynapseSpark) Compute() BaseComputeImpl { + return BaseComputeImpl{ + ComputeLocation: s.ComputeLocation, + ComputeType: s.ComputeType, + CreatedOn: s.CreatedOn, + Description: s.Description, + DisableLocalAuth: s.DisableLocalAuth, + IsAttachedCompute: s.IsAttachedCompute, + ModifiedOn: s.ModifiedOn, + ProvisioningErrors: s.ProvisioningErrors, + ProvisioningState: s.ProvisioningState, + ResourceId: s.ResourceId, + } +} + +func (o *SynapseSpark) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *SynapseSpark) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} + +func (o *SynapseSpark) GetModifiedOnAsTime() (*time.Time, error) { + if o.ModifiedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *SynapseSpark) SetModifiedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedOn = &formatted +} + +var _ json.Marshaler = SynapseSpark{} + +func (s SynapseSpark) MarshalJSON() ([]byte, error) { + type wrapper SynapseSpark + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SynapseSpark: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SynapseSpark: %+v", err) + } + + decoded["computeType"] = "SynapseSpark" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SynapseSpark: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_synapsesparkproperties.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_synapsesparkproperties.go new file mode 100644 index 00000000000..78b3d2e5ea6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_synapsesparkproperties.go @@ -0,0 +1,17 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SynapseSparkProperties struct { + AutoPauseProperties *AutoPauseProperties `json:"autoPauseProperties,omitempty"` + AutoScaleProperties *AutoScaleProperties `json:"autoScaleProperties,omitempty"` + NodeCount *int64 `json:"nodeCount,omitempty"` + NodeSize *string `json:"nodeSize,omitempty"` + NodeSizeFamily *string `json:"nodeSizeFamily,omitempty"` + PoolName *string `json:"poolName,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + SparkVersion *string `json:"sparkVersion,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + WorkspaceName *string `json:"workspaceName,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_systemservice.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_systemservice.go new file mode 100644 index 00000000000..8d21f387886 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_systemservice.go @@ -0,0 +1,10 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SystemService struct { + PublicIPAddress *string `json:"publicIpAddress,omitempty"` + SystemServiceType *string `json:"systemServiceType,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_tmpfsoptions.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_tmpfsoptions.go new file mode 100644 index 00000000000..b9f8f9e6d30 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_tmpfsoptions.go @@ -0,0 +1,8 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TmpfsOptions struct { + Size *int64 `json:"size,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_useraccountcredentials.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_useraccountcredentials.go new file mode 100644 index 00000000000..0ab389fc16c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_useraccountcredentials.go @@ -0,0 +1,10 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserAccountCredentials struct { + AdminUserName string `json:"adminUserName"` + AdminUserPassword *string `json:"adminUserPassword,omitempty"` + AdminUserSshPublicKey *string `json:"adminUserSshPublicKey,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_virtualmachine.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_virtualmachine.go new file mode 100644 index 00000000000..5ab5de8c18f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_virtualmachine.go @@ -0,0 +1,95 @@ +package machinelearningcomputes + +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. + +var _ Compute = VirtualMachine{} + +type VirtualMachine struct { + Properties *VirtualMachineSchemaProperties `json:"properties,omitempty"` + + // Fields inherited from Compute + + ComputeLocation *string `json:"computeLocation,omitempty"` + ComputeType ComputeType `json:"computeType"` + CreatedOn *string `json:"createdOn,omitempty"` + Description *string `json:"description,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + IsAttachedCompute *bool `json:"isAttachedCompute,omitempty"` + ModifiedOn *string `json:"modifiedOn,omitempty"` + ProvisioningErrors *[]ErrorResponse `json:"provisioningErrors,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} + +func (s VirtualMachine) Compute() BaseComputeImpl { + return BaseComputeImpl{ + ComputeLocation: s.ComputeLocation, + ComputeType: s.ComputeType, + CreatedOn: s.CreatedOn, + Description: s.Description, + DisableLocalAuth: s.DisableLocalAuth, + IsAttachedCompute: s.IsAttachedCompute, + ModifiedOn: s.ModifiedOn, + ProvisioningErrors: s.ProvisioningErrors, + ProvisioningState: s.ProvisioningState, + ResourceId: s.ResourceId, + } +} + +func (o *VirtualMachine) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *VirtualMachine) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} + +func (o *VirtualMachine) GetModifiedOnAsTime() (*time.Time, error) { + if o.ModifiedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *VirtualMachine) SetModifiedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedOn = &formatted +} + +var _ json.Marshaler = VirtualMachine{} + +func (s VirtualMachine) MarshalJSON() ([]byte, error) { + type wrapper VirtualMachine + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VirtualMachine: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VirtualMachine: %+v", err) + } + + decoded["computeType"] = "VirtualMachine" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VirtualMachine: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_virtualmachineimage.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_virtualmachineimage.go new file mode 100644 index 00000000000..9f5b42c0e08 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_virtualmachineimage.go @@ -0,0 +1,8 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineImage struct { + Id string `json:"id"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_virtualmachineschemaproperties.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_virtualmachineschemaproperties.go new file mode 100644 index 00000000000..234cb9957ed --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_virtualmachineschemaproperties.go @@ -0,0 +1,13 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineSchemaProperties struct { + Address *string `json:"address,omitempty"` + AdministratorAccount *VirtualMachineSshCredentials `json:"administratorAccount,omitempty"` + IsNotebookInstanceCompute *bool `json:"isNotebookInstanceCompute,omitempty"` + NotebookServerPort *int64 `json:"notebookServerPort,omitempty"` + SshPort *int64 `json:"sshPort,omitempty"` + VirtualMachineSize *string `json:"virtualMachineSize,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_virtualmachinesecrets.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_virtualmachinesecrets.go new file mode 100644 index 00000000000..b31384b4a2e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_virtualmachinesecrets.go @@ -0,0 +1,50 @@ +package machinelearningcomputes + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ComputeSecrets = VirtualMachineSecrets{} + +type VirtualMachineSecrets struct { + AdministratorAccount *VirtualMachineSshCredentials `json:"administratorAccount,omitempty"` + + // Fields inherited from ComputeSecrets + + ComputeType ComputeType `json:"computeType"` +} + +func (s VirtualMachineSecrets) ComputeSecrets() BaseComputeSecretsImpl { + return BaseComputeSecretsImpl{ + ComputeType: s.ComputeType, + } +} + +var _ json.Marshaler = VirtualMachineSecrets{} + +func (s VirtualMachineSecrets) MarshalJSON() ([]byte, error) { + type wrapper VirtualMachineSecrets + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VirtualMachineSecrets: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VirtualMachineSecrets: %+v", err) + } + + decoded["computeType"] = "VirtualMachine" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VirtualMachineSecrets: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_virtualmachinesshcredentials.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_virtualmachinesshcredentials.go new file mode 100644 index 00000000000..980c4958b1b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_virtualmachinesshcredentials.go @@ -0,0 +1,11 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineSshCredentials struct { + Password *string `json:"password,omitempty"` + PrivateKeyData *string `json:"privateKeyData,omitempty"` + PublicKeyData *string `json:"publicKeyData,omitempty"` + Username *string `json:"username,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_volumedefinition.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_volumedefinition.go new file mode 100644 index 00000000000..661018e409b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_volumedefinition.go @@ -0,0 +1,15 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeDefinition struct { + Bind *BindOptions `json:"bind,omitempty"` + Consistency *string `json:"consistency,omitempty"` + ReadOnly *bool `json:"readOnly,omitempty"` + Source *string `json:"source,omitempty"` + Target *string `json:"target,omitempty"` + Tmpfs *TmpfsOptions `json:"tmpfs,omitempty"` + Type *VolumeDefinitionType `json:"type,omitempty"` + Volume *VolumeOptions `json:"volume,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_volumeoptions.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_volumeoptions.go new file mode 100644 index 00000000000..6933407ec00 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/model_volumeoptions.go @@ -0,0 +1,8 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeOptions struct { + Nocopy *bool `json:"nocopy,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/predicates.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/predicates.go new file mode 100644 index 00000000000..d6f678c5c4c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/predicates.go @@ -0,0 +1,45 @@ +package machinelearningcomputes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AmlComputeNodesInformationOperationPredicate struct { + NextLink *string +} + +func (p AmlComputeNodesInformationOperationPredicate) Matches(input AmlComputeNodesInformation) bool { + + if p.NextLink != nil && (input.NextLink == nil || *p.NextLink != *input.NextLink) { + return false + } + + return true +} + +type ComputeResourceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ComputeResourceOperationPredicate) Matches(input ComputeResource) 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/machinelearningservices/2025-04-01/machinelearningcomputes/version.go b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/version.go new file mode 100644 index 00000000000..352e6538011 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/machinelearningcomputes/version.go @@ -0,0 +1,10 @@ +package machinelearningcomputes + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/machinelearningcomputes/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/managednetwork/README.md b/resource-manager/machinelearningservices/2025-04-01/managednetwork/README.md new file mode 100644 index 00000000000..4bd63268991 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/managednetwork/README.md @@ -0,0 +1,99 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/managednetwork` Documentation + +The `managednetwork` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/managednetwork" +``` + + +### Client Initialization + +```go +client := managednetwork.NewManagedNetworkClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ManagedNetworkClient.ProvisionsProvisionManagedNetwork` + +```go +ctx := context.TODO() +id := managednetwork.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +payload := managednetwork.ManagedNetworkProvisionOptions{ + // ... +} + + +if err := client.ProvisionsProvisionManagedNetworkThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedNetworkClient.SettingsRuleCreateOrUpdate` + +```go +ctx := context.TODO() +id := managednetwork.NewOutboundRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "outboundRuleName") + +payload := managednetwork.OutboundRuleBasicResource{ + // ... +} + + +if err := client.SettingsRuleCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedNetworkClient.SettingsRuleDelete` + +```go +ctx := context.TODO() +id := managednetwork.NewOutboundRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "outboundRuleName") + +if err := client.SettingsRuleDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ManagedNetworkClient.SettingsRuleGet` + +```go +ctx := context.TODO() +id := managednetwork.NewOutboundRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "outboundRuleName") + +read, err := client.SettingsRuleGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ManagedNetworkClient.SettingsRuleList` + +```go +ctx := context.TODO() +id := managednetwork.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +// alternatively `client.SettingsRuleList(ctx, id)` can be used to do batched pagination +items, err := client.SettingsRuleListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/managednetwork/client.go b/resource-manager/machinelearningservices/2025-04-01/managednetwork/client.go new file mode 100644 index 00000000000..7167dbc42a4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/managednetwork/client.go @@ -0,0 +1,26 @@ +package managednetwork + +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 ManagedNetworkClient struct { + Client *resourcemanager.Client +} + +func NewManagedNetworkClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedNetworkClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "managednetwork", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedNetworkClient: %+v", err) + } + + return &ManagedNetworkClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/managednetwork/constants.go b/resource-manager/machinelearningservices/2025-04-01/managednetwork/constants.go new file mode 100644 index 00000000000..bc80df92711 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/managednetwork/constants.go @@ -0,0 +1,233 @@ +package managednetwork + +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 ManagedNetworkStatus string + +const ( + ManagedNetworkStatusActive ManagedNetworkStatus = "Active" + ManagedNetworkStatusInactive ManagedNetworkStatus = "Inactive" +) + +func PossibleValuesForManagedNetworkStatus() []string { + return []string{ + string(ManagedNetworkStatusActive), + string(ManagedNetworkStatusInactive), + } +} + +func (s *ManagedNetworkStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedNetworkStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedNetworkStatus(input string) (*ManagedNetworkStatus, error) { + vals := map[string]ManagedNetworkStatus{ + "active": ManagedNetworkStatusActive, + "inactive": ManagedNetworkStatusInactive, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedNetworkStatus(input) + return &out, nil +} + +type RuleAction string + +const ( + RuleActionAllow RuleAction = "Allow" + RuleActionDeny RuleAction = "Deny" +) + +func PossibleValuesForRuleAction() []string { + return []string{ + string(RuleActionAllow), + string(RuleActionDeny), + } +} + +func (s *RuleAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRuleAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRuleAction(input string) (*RuleAction, error) { + vals := map[string]RuleAction{ + "allow": RuleActionAllow, + "deny": RuleActionDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RuleAction(input) + return &out, nil +} + +type RuleCategory string + +const ( + RuleCategoryDependency RuleCategory = "Dependency" + RuleCategoryRecommended RuleCategory = "Recommended" + RuleCategoryRequired RuleCategory = "Required" + RuleCategoryUserDefined RuleCategory = "UserDefined" +) + +func PossibleValuesForRuleCategory() []string { + return []string{ + string(RuleCategoryDependency), + string(RuleCategoryRecommended), + string(RuleCategoryRequired), + string(RuleCategoryUserDefined), + } +} + +func (s *RuleCategory) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRuleCategory(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRuleCategory(input string) (*RuleCategory, error) { + vals := map[string]RuleCategory{ + "dependency": RuleCategoryDependency, + "recommended": RuleCategoryRecommended, + "required": RuleCategoryRequired, + "userdefined": RuleCategoryUserDefined, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RuleCategory(input) + return &out, nil +} + +type RuleStatus string + +const ( + RuleStatusActive RuleStatus = "Active" + RuleStatusDeleting RuleStatus = "Deleting" + RuleStatusFailed RuleStatus = "Failed" + RuleStatusInactive RuleStatus = "Inactive" + RuleStatusProvisioning RuleStatus = "Provisioning" +) + +func PossibleValuesForRuleStatus() []string { + return []string{ + string(RuleStatusActive), + string(RuleStatusDeleting), + string(RuleStatusFailed), + string(RuleStatusInactive), + string(RuleStatusProvisioning), + } +} + +func (s *RuleStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRuleStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRuleStatus(input string) (*RuleStatus, error) { + vals := map[string]RuleStatus{ + "active": RuleStatusActive, + "deleting": RuleStatusDeleting, + "failed": RuleStatusFailed, + "inactive": RuleStatusInactive, + "provisioning": RuleStatusProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RuleStatus(input) + return &out, nil +} + +type RuleType string + +const ( + RuleTypeFQDN RuleType = "FQDN" + RuleTypePrivateEndpoint RuleType = "PrivateEndpoint" + RuleTypeServiceTag RuleType = "ServiceTag" +) + +func PossibleValuesForRuleType() []string { + return []string{ + string(RuleTypeFQDN), + string(RuleTypePrivateEndpoint), + string(RuleTypeServiceTag), + } +} + +func (s *RuleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRuleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRuleType(input string) (*RuleType, error) { + vals := map[string]RuleType{ + "fqdn": RuleTypeFQDN, + "privateendpoint": RuleTypePrivateEndpoint, + "servicetag": RuleTypeServiceTag, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RuleType(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/managednetwork/id_outboundrule.go b/resource-manager/machinelearningservices/2025-04-01/managednetwork/id_outboundrule.go new file mode 100644 index 00000000000..16202df94be --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/managednetwork/id_outboundrule.go @@ -0,0 +1,139 @@ +package managednetwork + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&OutboundRuleId{}) +} + +var _ resourceids.ResourceId = &OutboundRuleId{} + +// OutboundRuleId is a struct representing the Resource ID for a Outbound Rule +type OutboundRuleId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + OutboundRuleName string +} + +// NewOutboundRuleID returns a new OutboundRuleId struct +func NewOutboundRuleID(subscriptionId string, resourceGroupName string, workspaceName string, outboundRuleName string) OutboundRuleId { + return OutboundRuleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + OutboundRuleName: outboundRuleName, + } +} + +// ParseOutboundRuleID parses 'input' into a OutboundRuleId +func ParseOutboundRuleID(input string) (*OutboundRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&OutboundRuleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := OutboundRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseOutboundRuleIDInsensitively parses 'input' case-insensitively into a OutboundRuleId +// note: this method should only be used for API response data and not user input +func ParseOutboundRuleIDInsensitively(input string) (*OutboundRuleId, error) { + parser := resourceids.NewParserFromResourceIdType(&OutboundRuleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := OutboundRuleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *OutboundRuleId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.OutboundRuleName, ok = input.Parsed["outboundRuleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "outboundRuleName", input) + } + + return nil +} + +// ValidateOutboundRuleID checks that 'input' can be parsed as a Outbound Rule ID +func ValidateOutboundRuleID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseOutboundRuleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Outbound Rule ID +func (id OutboundRuleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/outboundRules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.OutboundRuleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Outbound Rule ID +func (id OutboundRuleId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticOutboundRules", "outboundRules", "outboundRules"), + resourceids.UserSpecifiedSegment("outboundRuleName", "outboundRuleName"), + } +} + +// String returns a human-readable description of this Outbound Rule ID +func (id OutboundRuleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Outbound Rule Name: %q", id.OutboundRuleName), + } + return fmt.Sprintf("Outbound Rule (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/managednetwork/id_outboundrule_test.go b/resource-manager/machinelearningservices/2025-04-01/managednetwork/id_outboundrule_test.go new file mode 100644 index 00000000000..6529777f0f1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/managednetwork/id_outboundrule_test.go @@ -0,0 +1,327 @@ +package managednetwork + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &OutboundRuleId{} + +func TestNewOutboundRuleID(t *testing.T) { + id := NewOutboundRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "outboundRuleName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.OutboundRuleName != "outboundRuleName" { + t.Fatalf("Expected %q but got %q for Segment 'OutboundRuleName'", id.OutboundRuleName, "outboundRuleName") + } +} + +func TestFormatOutboundRuleID(t *testing.T) { + actual := NewOutboundRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "outboundRuleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/outboundRules/outboundRuleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseOutboundRuleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *OutboundRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/outboundRules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/outboundRules/outboundRuleName", + Expected: &OutboundRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + OutboundRuleName: "outboundRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/outboundRules/outboundRuleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseOutboundRuleID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.OutboundRuleName != v.Expected.OutboundRuleName { + t.Fatalf("Expected %q but got %q for OutboundRuleName", v.Expected.OutboundRuleName, actual.OutboundRuleName) + } + + } +} + +func TestParseOutboundRuleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *OutboundRuleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/outboundRules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/oUtBoUnDrUlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/outboundRules/outboundRuleName", + Expected: &OutboundRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + OutboundRuleName: "outboundRuleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/outboundRules/outboundRuleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/oUtBoUnDrUlEs/oUtBoUnDrUlEnAmE", + Expected: &OutboundRuleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + OutboundRuleName: "oUtBoUnDrUlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/oUtBoUnDrUlEs/oUtBoUnDrUlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseOutboundRuleIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.OutboundRuleName != v.Expected.OutboundRuleName { + t.Fatalf("Expected %q but got %q for OutboundRuleName", v.Expected.OutboundRuleName, actual.OutboundRuleName) + } + + } +} + +func TestSegmentsForOutboundRuleId(t *testing.T) { + segments := OutboundRuleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("OutboundRuleId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/managednetwork/id_workspace.go b/resource-manager/machinelearningservices/2025-04-01/managednetwork/id_workspace.go new file mode 100644 index 00000000000..f90b3b23885 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/managednetwork/id_workspace.go @@ -0,0 +1,130 @@ +package managednetwork + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/managednetwork/id_workspace_test.go b/resource-manager/machinelearningservices/2025-04-01/managednetwork/id_workspace_test.go new file mode 100644 index 00000000000..71e49b4b55f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/managednetwork/id_workspace_test.go @@ -0,0 +1,282 @@ +package managednetwork + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/managednetwork/method_provisionsprovisionmanagednetwork.go b/resource-manager/machinelearningservices/2025-04-01/managednetwork/method_provisionsprovisionmanagednetwork.go new file mode 100644 index 00000000000..e35f68f85d2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/managednetwork/method_provisionsprovisionmanagednetwork.go @@ -0,0 +1,75 @@ +package managednetwork + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProvisionsProvisionManagedNetworkOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ManagedNetworkProvisionStatus +} + +// ProvisionsProvisionManagedNetwork ... +func (c ManagedNetworkClient) ProvisionsProvisionManagedNetwork(ctx context.Context, id WorkspaceId, input ManagedNetworkProvisionOptions) (result ProvisionsProvisionManagedNetworkOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/provisionManagedNetwork", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ProvisionsProvisionManagedNetworkThenPoll performs ProvisionsProvisionManagedNetwork then polls until it's completed +func (c ManagedNetworkClient) ProvisionsProvisionManagedNetworkThenPoll(ctx context.Context, id WorkspaceId, input ManagedNetworkProvisionOptions) error { + result, err := c.ProvisionsProvisionManagedNetwork(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ProvisionsProvisionManagedNetwork: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ProvisionsProvisionManagedNetwork: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/managednetwork/method_settingsrulecreateorupdate.go b/resource-manager/machinelearningservices/2025-04-01/managednetwork/method_settingsrulecreateorupdate.go new file mode 100644 index 00000000000..9e4eec71434 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/managednetwork/method_settingsrulecreateorupdate.go @@ -0,0 +1,75 @@ +package managednetwork + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SettingsRuleCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *OutboundRuleBasicResource +} + +// SettingsRuleCreateOrUpdate ... +func (c ManagedNetworkClient) SettingsRuleCreateOrUpdate(ctx context.Context, id OutboundRuleId, input OutboundRuleBasicResource) (result SettingsRuleCreateOrUpdateOperationResponse, 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 +} + +// SettingsRuleCreateOrUpdateThenPoll performs SettingsRuleCreateOrUpdate then polls until it's completed +func (c ManagedNetworkClient) SettingsRuleCreateOrUpdateThenPoll(ctx context.Context, id OutboundRuleId, input OutboundRuleBasicResource) error { + result, err := c.SettingsRuleCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing SettingsRuleCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SettingsRuleCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/managednetwork/method_settingsruledelete.go b/resource-manager/machinelearningservices/2025-04-01/managednetwork/method_settingsruledelete.go new file mode 100644 index 00000000000..6306e801dd7 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/managednetwork/method_settingsruledelete.go @@ -0,0 +1,71 @@ +package managednetwork + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SettingsRuleDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// SettingsRuleDelete ... +func (c ManagedNetworkClient) SettingsRuleDelete(ctx context.Context, id OutboundRuleId) (result SettingsRuleDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// SettingsRuleDeleteThenPoll performs SettingsRuleDelete then polls until it's completed +func (c ManagedNetworkClient) SettingsRuleDeleteThenPoll(ctx context.Context, id OutboundRuleId) error { + result, err := c.SettingsRuleDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing SettingsRuleDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after SettingsRuleDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/managednetwork/method_settingsruleget.go b/resource-manager/machinelearningservices/2025-04-01/managednetwork/method_settingsruleget.go new file mode 100644 index 00000000000..d9e4990d783 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/managednetwork/method_settingsruleget.go @@ -0,0 +1,53 @@ +package managednetwork + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SettingsRuleGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *OutboundRuleBasicResource +} + +// SettingsRuleGet ... +func (c ManagedNetworkClient) SettingsRuleGet(ctx context.Context, id OutboundRuleId) (result SettingsRuleGetOperationResponse, 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 OutboundRuleBasicResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/managednetwork/method_settingsrulelist.go b/resource-manager/machinelearningservices/2025-04-01/managednetwork/method_settingsrulelist.go new file mode 100644 index 00000000000..b73fd89a69d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/managednetwork/method_settingsrulelist.go @@ -0,0 +1,105 @@ +package managednetwork + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SettingsRuleListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]OutboundRuleBasicResource +} + +type SettingsRuleListCompleteResult struct { + LatestHttpResponse *http.Response + Items []OutboundRuleBasicResource +} + +type SettingsRuleListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *SettingsRuleListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// SettingsRuleList ... +func (c ManagedNetworkClient) SettingsRuleList(ctx context.Context, id WorkspaceId) (result SettingsRuleListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &SettingsRuleListCustomPager{}, + Path: fmt.Sprintf("%s/outboundRules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]OutboundRuleBasicResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// SettingsRuleListComplete retrieves all the results into a single object +func (c ManagedNetworkClient) SettingsRuleListComplete(ctx context.Context, id WorkspaceId) (SettingsRuleListCompleteResult, error) { + return c.SettingsRuleListCompleteMatchingPredicate(ctx, id, OutboundRuleBasicResourceOperationPredicate{}) +} + +// SettingsRuleListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ManagedNetworkClient) SettingsRuleListCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, predicate OutboundRuleBasicResourceOperationPredicate) (result SettingsRuleListCompleteResult, err error) { + items := make([]OutboundRuleBasicResource, 0) + + resp, err := c.SettingsRuleList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = SettingsRuleListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_fqdnoutboundrule.go b/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_fqdnoutboundrule.go new file mode 100644 index 00000000000..2796db8ade8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_fqdnoutboundrule.go @@ -0,0 +1,58 @@ +package managednetwork + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ OutboundRule = FqdnOutboundRule{} + +type FqdnOutboundRule struct { + Destination *string `json:"destination,omitempty"` + + // Fields inherited from OutboundRule + + Category *RuleCategory `json:"category,omitempty"` + ErrorInformation *string `json:"errorInformation,omitempty"` + ParentRuleNames *[]string `json:"parentRuleNames,omitempty"` + Status *RuleStatus `json:"status,omitempty"` + Type RuleType `json:"type"` +} + +func (s FqdnOutboundRule) OutboundRule() BaseOutboundRuleImpl { + return BaseOutboundRuleImpl{ + Category: s.Category, + ErrorInformation: s.ErrorInformation, + ParentRuleNames: s.ParentRuleNames, + Status: s.Status, + Type: s.Type, + } +} + +var _ json.Marshaler = FqdnOutboundRule{} + +func (s FqdnOutboundRule) MarshalJSON() ([]byte, error) { + type wrapper FqdnOutboundRule + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling FqdnOutboundRule: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling FqdnOutboundRule: %+v", err) + } + + decoded["type"] = "FQDN" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling FqdnOutboundRule: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_managednetworkprovisionoptions.go b/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_managednetworkprovisionoptions.go new file mode 100644 index 00000000000..4d2c0367305 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_managednetworkprovisionoptions.go @@ -0,0 +1,8 @@ +package managednetwork + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedNetworkProvisionOptions struct { + IncludeSpark *bool `json:"includeSpark,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_managednetworkprovisionstatus.go b/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_managednetworkprovisionstatus.go new file mode 100644 index 00000000000..3010b961a34 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_managednetworkprovisionstatus.go @@ -0,0 +1,9 @@ +package managednetwork + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedNetworkProvisionStatus struct { + SparkReady *bool `json:"sparkReady,omitempty"` + Status *ManagedNetworkStatus `json:"status,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_outboundrule.go b/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_outboundrule.go new file mode 100644 index 00000000000..ebebb14698f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_outboundrule.go @@ -0,0 +1,95 @@ +package managednetwork + +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 OutboundRule interface { + OutboundRule() BaseOutboundRuleImpl +} + +var _ OutboundRule = BaseOutboundRuleImpl{} + +type BaseOutboundRuleImpl struct { + Category *RuleCategory `json:"category,omitempty"` + ErrorInformation *string `json:"errorInformation,omitempty"` + ParentRuleNames *[]string `json:"parentRuleNames,omitempty"` + Status *RuleStatus `json:"status,omitempty"` + Type RuleType `json:"type"` +} + +func (s BaseOutboundRuleImpl) OutboundRule() BaseOutboundRuleImpl { + return s +} + +var _ OutboundRule = RawOutboundRuleImpl{} + +// RawOutboundRuleImpl 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 RawOutboundRuleImpl struct { + outboundRule BaseOutboundRuleImpl + Type string + Values map[string]interface{} +} + +func (s RawOutboundRuleImpl) OutboundRule() BaseOutboundRuleImpl { + return s.outboundRule +} + +func UnmarshalOutboundRuleImplementation(input []byte) (OutboundRule, 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 OutboundRule into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["type"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "FQDN") { + var out FqdnOutboundRule + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into FqdnOutboundRule: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "PrivateEndpoint") { + var out PrivateEndpointOutboundRule + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into PrivateEndpointOutboundRule: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ServiceTag") { + var out ServiceTagOutboundRule + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ServiceTagOutboundRule: %+v", err) + } + return out, nil + } + + var parent BaseOutboundRuleImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseOutboundRuleImpl: %+v", err) + } + + return RawOutboundRuleImpl{ + outboundRule: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_outboundrulebasicresource.go b/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_outboundrulebasicresource.go new file mode 100644 index 00000000000..8abeca48308 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_outboundrulebasicresource.go @@ -0,0 +1,53 @@ +package managednetwork + +import ( + "encoding/json" + "fmt" + + "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 OutboundRuleBasicResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties OutboundRule `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &OutboundRuleBasicResource{} + +func (s *OutboundRuleBasicResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Id = decoded.Id + s.Name = decoded.Name + s.SystemData = decoded.SystemData + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling OutboundRuleBasicResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalOutboundRuleImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'OutboundRuleBasicResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_privateendpointdestination.go b/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_privateendpointdestination.go new file mode 100644 index 00000000000..30060d85562 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_privateendpointdestination.go @@ -0,0 +1,11 @@ +package managednetwork + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointDestination struct { + ServiceResourceId *string `json:"serviceResourceId,omitempty"` + SparkEnabled *bool `json:"sparkEnabled,omitempty"` + SparkStatus *RuleStatus `json:"sparkStatus,omitempty"` + SubresourceTarget *string `json:"subresourceTarget,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_privateendpointoutboundrule.go b/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_privateendpointoutboundrule.go new file mode 100644 index 00000000000..669eb11513e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_privateendpointoutboundrule.go @@ -0,0 +1,58 @@ +package managednetwork + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ OutboundRule = PrivateEndpointOutboundRule{} + +type PrivateEndpointOutboundRule struct { + Destination *PrivateEndpointDestination `json:"destination,omitempty"` + + // Fields inherited from OutboundRule + + Category *RuleCategory `json:"category,omitempty"` + ErrorInformation *string `json:"errorInformation,omitempty"` + ParentRuleNames *[]string `json:"parentRuleNames,omitempty"` + Status *RuleStatus `json:"status,omitempty"` + Type RuleType `json:"type"` +} + +func (s PrivateEndpointOutboundRule) OutboundRule() BaseOutboundRuleImpl { + return BaseOutboundRuleImpl{ + Category: s.Category, + ErrorInformation: s.ErrorInformation, + ParentRuleNames: s.ParentRuleNames, + Status: s.Status, + Type: s.Type, + } +} + +var _ json.Marshaler = PrivateEndpointOutboundRule{} + +func (s PrivateEndpointOutboundRule) MarshalJSON() ([]byte, error) { + type wrapper PrivateEndpointOutboundRule + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling PrivateEndpointOutboundRule: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling PrivateEndpointOutboundRule: %+v", err) + } + + decoded["type"] = "PrivateEndpoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling PrivateEndpointOutboundRule: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_servicetagdestination.go b/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_servicetagdestination.go new file mode 100644 index 00000000000..efbbd4e7c8d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_servicetagdestination.go @@ -0,0 +1,12 @@ +package managednetwork + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceTagDestination struct { + Action *RuleAction `json:"action,omitempty"` + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + PortRanges *string `json:"portRanges,omitempty"` + Protocol *string `json:"protocol,omitempty"` + ServiceTag *string `json:"serviceTag,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_servicetagoutboundrule.go b/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_servicetagoutboundrule.go new file mode 100644 index 00000000000..831449767d4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/managednetwork/model_servicetagoutboundrule.go @@ -0,0 +1,58 @@ +package managednetwork + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ OutboundRule = ServiceTagOutboundRule{} + +type ServiceTagOutboundRule struct { + Destination *ServiceTagDestination `json:"destination,omitempty"` + + // Fields inherited from OutboundRule + + Category *RuleCategory `json:"category,omitempty"` + ErrorInformation *string `json:"errorInformation,omitempty"` + ParentRuleNames *[]string `json:"parentRuleNames,omitempty"` + Status *RuleStatus `json:"status,omitempty"` + Type RuleType `json:"type"` +} + +func (s ServiceTagOutboundRule) OutboundRule() BaseOutboundRuleImpl { + return BaseOutboundRuleImpl{ + Category: s.Category, + ErrorInformation: s.ErrorInformation, + ParentRuleNames: s.ParentRuleNames, + Status: s.Status, + Type: s.Type, + } +} + +var _ json.Marshaler = ServiceTagOutboundRule{} + +func (s ServiceTagOutboundRule) MarshalJSON() ([]byte, error) { + type wrapper ServiceTagOutboundRule + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ServiceTagOutboundRule: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ServiceTagOutboundRule: %+v", err) + } + + decoded["type"] = "ServiceTag" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ServiceTagOutboundRule: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/managednetwork/predicates.go b/resource-manager/machinelearningservices/2025-04-01/managednetwork/predicates.go new file mode 100644 index 00000000000..960a0afdff5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/managednetwork/predicates.go @@ -0,0 +1,27 @@ +package managednetwork + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OutboundRuleBasicResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p OutboundRuleBasicResourceOperationPredicate) Matches(input OutboundRuleBasicResource) 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/machinelearningservices/2025-04-01/managednetwork/version.go b/resource-manager/machinelearningservices/2025-04-01/managednetwork/version.go new file mode 100644 index 00000000000..a3a943cce7c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/managednetwork/version.go @@ -0,0 +1,10 @@ +package managednetwork + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/managednetwork/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/README.md b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/README.md new file mode 100644 index 00000000000..7f40852e7f6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription` Documentation + +The `marketplacesubscription` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription" +``` + + +### Client Initialization + +```go +client := marketplacesubscription.NewMarketplaceSubscriptionClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `MarketplaceSubscriptionClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := marketplacesubscription.NewMarketplaceSubscriptionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "marketplaceSubscriptionName") + +payload := marketplacesubscription.MarketplaceSubscriptionResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `MarketplaceSubscriptionClient.Delete` + +```go +ctx := context.TODO() +id := marketplacesubscription.NewMarketplaceSubscriptionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "marketplaceSubscriptionName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `MarketplaceSubscriptionClient.Get` + +```go +ctx := context.TODO() +id := marketplacesubscription.NewMarketplaceSubscriptionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "marketplaceSubscriptionName") + +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: `MarketplaceSubscriptionClient.List` + +```go +ctx := context.TODO() +id := marketplacesubscription.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +// alternatively `client.List(ctx, id, marketplacesubscription.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, marketplacesubscription.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/client.go b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/client.go new file mode 100644 index 00000000000..87f641f00f2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/client.go @@ -0,0 +1,26 @@ +package marketplacesubscription + +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 MarketplaceSubscriptionClient struct { + Client *resourcemanager.Client +} + +func NewMarketplaceSubscriptionClientWithBaseURI(sdkApi sdkEnv.Api) (*MarketplaceSubscriptionClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "marketplacesubscription", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating MarketplaceSubscriptionClient: %+v", err) + } + + return &MarketplaceSubscriptionClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/constants.go b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/constants.go new file mode 100644 index 00000000000..1c19d6e3dca --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/constants.go @@ -0,0 +1,107 @@ +package marketplacesubscription + +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 MarketplaceSubscriptionProvisioningState string + +const ( + MarketplaceSubscriptionProvisioningStateCanceled MarketplaceSubscriptionProvisioningState = "Canceled" + MarketplaceSubscriptionProvisioningStateCreating MarketplaceSubscriptionProvisioningState = "Creating" + MarketplaceSubscriptionProvisioningStateDeleting MarketplaceSubscriptionProvisioningState = "Deleting" + MarketplaceSubscriptionProvisioningStateFailed MarketplaceSubscriptionProvisioningState = "Failed" + MarketplaceSubscriptionProvisioningStateSucceeded MarketplaceSubscriptionProvisioningState = "Succeeded" + MarketplaceSubscriptionProvisioningStateUpdating MarketplaceSubscriptionProvisioningState = "Updating" +) + +func PossibleValuesForMarketplaceSubscriptionProvisioningState() []string { + return []string{ + string(MarketplaceSubscriptionProvisioningStateCanceled), + string(MarketplaceSubscriptionProvisioningStateCreating), + string(MarketplaceSubscriptionProvisioningStateDeleting), + string(MarketplaceSubscriptionProvisioningStateFailed), + string(MarketplaceSubscriptionProvisioningStateSucceeded), + string(MarketplaceSubscriptionProvisioningStateUpdating), + } +} + +func (s *MarketplaceSubscriptionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMarketplaceSubscriptionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMarketplaceSubscriptionProvisioningState(input string) (*MarketplaceSubscriptionProvisioningState, error) { + vals := map[string]MarketplaceSubscriptionProvisioningState{ + "canceled": MarketplaceSubscriptionProvisioningStateCanceled, + "creating": MarketplaceSubscriptionProvisioningStateCreating, + "deleting": MarketplaceSubscriptionProvisioningStateDeleting, + "failed": MarketplaceSubscriptionProvisioningStateFailed, + "succeeded": MarketplaceSubscriptionProvisioningStateSucceeded, + "updating": MarketplaceSubscriptionProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MarketplaceSubscriptionProvisioningState(input) + return &out, nil +} + +type MarketplaceSubscriptionStatus string + +const ( + MarketplaceSubscriptionStatusSubscribed MarketplaceSubscriptionStatus = "Subscribed" + MarketplaceSubscriptionStatusSuspended MarketplaceSubscriptionStatus = "Suspended" + MarketplaceSubscriptionStatusUnsubscribed MarketplaceSubscriptionStatus = "Unsubscribed" +) + +func PossibleValuesForMarketplaceSubscriptionStatus() []string { + return []string{ + string(MarketplaceSubscriptionStatusSubscribed), + string(MarketplaceSubscriptionStatusSuspended), + string(MarketplaceSubscriptionStatusUnsubscribed), + } +} + +func (s *MarketplaceSubscriptionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMarketplaceSubscriptionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMarketplaceSubscriptionStatus(input string) (*MarketplaceSubscriptionStatus, error) { + vals := map[string]MarketplaceSubscriptionStatus{ + "subscribed": MarketplaceSubscriptionStatusSubscribed, + "suspended": MarketplaceSubscriptionStatusSuspended, + "unsubscribed": MarketplaceSubscriptionStatusUnsubscribed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MarketplaceSubscriptionStatus(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/id_marketplacesubscription.go b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/id_marketplacesubscription.go new file mode 100644 index 00000000000..aec46394760 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/id_marketplacesubscription.go @@ -0,0 +1,139 @@ +package marketplacesubscription + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&MarketplaceSubscriptionId{}) +} + +var _ resourceids.ResourceId = &MarketplaceSubscriptionId{} + +// MarketplaceSubscriptionId is a struct representing the Resource ID for a Marketplace Subscription +type MarketplaceSubscriptionId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + MarketplaceSubscriptionName string +} + +// NewMarketplaceSubscriptionID returns a new MarketplaceSubscriptionId struct +func NewMarketplaceSubscriptionID(subscriptionId string, resourceGroupName string, workspaceName string, marketplaceSubscriptionName string) MarketplaceSubscriptionId { + return MarketplaceSubscriptionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + MarketplaceSubscriptionName: marketplaceSubscriptionName, + } +} + +// ParseMarketplaceSubscriptionID parses 'input' into a MarketplaceSubscriptionId +func ParseMarketplaceSubscriptionID(input string) (*MarketplaceSubscriptionId, error) { + parser := resourceids.NewParserFromResourceIdType(&MarketplaceSubscriptionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MarketplaceSubscriptionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseMarketplaceSubscriptionIDInsensitively parses 'input' case-insensitively into a MarketplaceSubscriptionId +// note: this method should only be used for API response data and not user input +func ParseMarketplaceSubscriptionIDInsensitively(input string) (*MarketplaceSubscriptionId, error) { + parser := resourceids.NewParserFromResourceIdType(&MarketplaceSubscriptionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := MarketplaceSubscriptionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *MarketplaceSubscriptionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.MarketplaceSubscriptionName, ok = input.Parsed["marketplaceSubscriptionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "marketplaceSubscriptionName", input) + } + + return nil +} + +// ValidateMarketplaceSubscriptionID checks that 'input' can be parsed as a Marketplace Subscription ID +func ValidateMarketplaceSubscriptionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseMarketplaceSubscriptionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Marketplace Subscription ID +func (id MarketplaceSubscriptionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/marketplaceSubscriptions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.MarketplaceSubscriptionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Marketplace Subscription ID +func (id MarketplaceSubscriptionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticMarketplaceSubscriptions", "marketplaceSubscriptions", "marketplaceSubscriptions"), + resourceids.UserSpecifiedSegment("marketplaceSubscriptionName", "marketplaceSubscriptionName"), + } +} + +// String returns a human-readable description of this Marketplace Subscription ID +func (id MarketplaceSubscriptionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Marketplace Subscription Name: %q", id.MarketplaceSubscriptionName), + } + return fmt.Sprintf("Marketplace Subscription (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/id_marketplacesubscription_test.go b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/id_marketplacesubscription_test.go new file mode 100644 index 00000000000..edbe4ef916f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/id_marketplacesubscription_test.go @@ -0,0 +1,327 @@ +package marketplacesubscription + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &MarketplaceSubscriptionId{} + +func TestNewMarketplaceSubscriptionID(t *testing.T) { + id := NewMarketplaceSubscriptionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "marketplaceSubscriptionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.MarketplaceSubscriptionName != "marketplaceSubscriptionName" { + t.Fatalf("Expected %q but got %q for Segment 'MarketplaceSubscriptionName'", id.MarketplaceSubscriptionName, "marketplaceSubscriptionName") + } +} + +func TestFormatMarketplaceSubscriptionID(t *testing.T) { + actual := NewMarketplaceSubscriptionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "marketplaceSubscriptionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/marketplaceSubscriptions/marketplaceSubscriptionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseMarketplaceSubscriptionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MarketplaceSubscriptionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/marketplaceSubscriptions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/marketplaceSubscriptions/marketplaceSubscriptionName", + Expected: &MarketplaceSubscriptionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + MarketplaceSubscriptionName: "marketplaceSubscriptionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/marketplaceSubscriptions/marketplaceSubscriptionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMarketplaceSubscriptionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.MarketplaceSubscriptionName != v.Expected.MarketplaceSubscriptionName { + t.Fatalf("Expected %q but got %q for MarketplaceSubscriptionName", v.Expected.MarketplaceSubscriptionName, actual.MarketplaceSubscriptionName) + } + + } +} + +func TestParseMarketplaceSubscriptionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *MarketplaceSubscriptionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/marketplaceSubscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/mArKeTpLaCeSuBsCrIpTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/marketplaceSubscriptions/marketplaceSubscriptionName", + Expected: &MarketplaceSubscriptionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + MarketplaceSubscriptionName: "marketplaceSubscriptionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/marketplaceSubscriptions/marketplaceSubscriptionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/mArKeTpLaCeSuBsCrIpTiOnS/mArKeTpLaCeSuBsCrIpTiOnNaMe", + Expected: &MarketplaceSubscriptionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + MarketplaceSubscriptionName: "mArKeTpLaCeSuBsCrIpTiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/mArKeTpLaCeSuBsCrIpTiOnS/mArKeTpLaCeSuBsCrIpTiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseMarketplaceSubscriptionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.MarketplaceSubscriptionName != v.Expected.MarketplaceSubscriptionName { + t.Fatalf("Expected %q but got %q for MarketplaceSubscriptionName", v.Expected.MarketplaceSubscriptionName, actual.MarketplaceSubscriptionName) + } + + } +} + +func TestSegmentsForMarketplaceSubscriptionId(t *testing.T) { + segments := MarketplaceSubscriptionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("MarketplaceSubscriptionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/id_workspace.go b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/id_workspace.go new file mode 100644 index 00000000000..70fbfe28961 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/id_workspace.go @@ -0,0 +1,130 @@ +package marketplacesubscription + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/id_workspace_test.go b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/id_workspace_test.go new file mode 100644 index 00000000000..06064196fc5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/id_workspace_test.go @@ -0,0 +1,282 @@ +package marketplacesubscription + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/method_createorupdate.go b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/method_createorupdate.go new file mode 100644 index 00000000000..a6b7de40273 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/method_createorupdate.go @@ -0,0 +1,75 @@ +package marketplacesubscription + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *MarketplaceSubscriptionResource +} + +// CreateOrUpdate ... +func (c MarketplaceSubscriptionClient) CreateOrUpdate(ctx context.Context, id MarketplaceSubscriptionId, input MarketplaceSubscriptionResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c MarketplaceSubscriptionClient) CreateOrUpdateThenPoll(ctx context.Context, id MarketplaceSubscriptionId, input MarketplaceSubscriptionResource) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/method_delete.go b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/method_delete.go new file mode 100644 index 00000000000..296405c26c7 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/method_delete.go @@ -0,0 +1,70 @@ +package marketplacesubscription + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 MarketplaceSubscriptionClient) Delete(ctx context.Context, id MarketplaceSubscriptionId) (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 MarketplaceSubscriptionClient) DeleteThenPoll(ctx context.Context, id MarketplaceSubscriptionId) 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/machinelearningservices/2025-04-01/marketplacesubscription/method_get.go b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/method_get.go new file mode 100644 index 00000000000..4cb6d762e69 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/method_get.go @@ -0,0 +1,53 @@ +package marketplacesubscription + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *MarketplaceSubscriptionResource +} + +// Get ... +func (c MarketplaceSubscriptionClient) Get(ctx context.Context, id MarketplaceSubscriptionId) (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 MarketplaceSubscriptionResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/method_list.go b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/method_list.go new file mode 100644 index 00000000000..65cac65016e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/method_list.go @@ -0,0 +1,134 @@ +package marketplacesubscription + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]MarketplaceSubscriptionResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []MarketplaceSubscriptionResource +} + +type ListOperationOptions struct { + Skip *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.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + 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 MarketplaceSubscriptionClient) List(ctx context.Context, id WorkspaceId, 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/marketplaceSubscriptions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]MarketplaceSubscriptionResource `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 MarketplaceSubscriptionClient) ListComplete(ctx context.Context, id WorkspaceId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, MarketplaceSubscriptionResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c MarketplaceSubscriptionClient) ListCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, options ListOperationOptions, predicate MarketplaceSubscriptionResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]MarketplaceSubscriptionResource, 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/machinelearningservices/2025-04-01/marketplacesubscription/model_marketplaceplan.go b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/model_marketplaceplan.go new file mode 100644 index 00000000000..74c3ecde0c0 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/model_marketplaceplan.go @@ -0,0 +1,10 @@ +package marketplacesubscription + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MarketplacePlan struct { + OfferId *string `json:"offerId,omitempty"` + PlanId *string `json:"planId,omitempty"` + PublisherId *string `json:"publisherId,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/model_marketplacesubscription.go b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/model_marketplacesubscription.go new file mode 100644 index 00000000000..6b5addd4875 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/model_marketplacesubscription.go @@ -0,0 +1,11 @@ +package marketplacesubscription + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MarketplaceSubscription struct { + MarketplacePlan *MarketplacePlan `json:"marketplacePlan,omitempty"` + MarketplaceSubscriptionStatus *MarketplaceSubscriptionStatus `json:"marketplaceSubscriptionStatus,omitempty"` + ModelId string `json:"modelId"` + ProvisioningState *MarketplaceSubscriptionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/model_marketplacesubscriptionresource.go b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/model_marketplacesubscriptionresource.go new file mode 100644 index 00000000000..5b386aed6e3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/model_marketplacesubscriptionresource.go @@ -0,0 +1,16 @@ +package marketplacesubscription + +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 MarketplaceSubscriptionResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties MarketplaceSubscription `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/predicates.go b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/predicates.go new file mode 100644 index 00000000000..8be47672689 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/predicates.go @@ -0,0 +1,27 @@ +package marketplacesubscription + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MarketplaceSubscriptionResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p MarketplaceSubscriptionResourceOperationPredicate) Matches(input MarketplaceSubscriptionResource) 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/machinelearningservices/2025-04-01/marketplacesubscription/version.go b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/version.go new file mode 100644 index 00000000000..d786cc98fc4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/marketplacesubscription/version.go @@ -0,0 +1,10 @@ +package marketplacesubscription + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/marketplacesubscription/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelcontainer/README.md b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/README.md new file mode 100644 index 00000000000..e87b8d7e845 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/README.md @@ -0,0 +1,152 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/modelcontainer` Documentation + +The `modelcontainer` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/modelcontainer" +``` + + +### Client Initialization + +```go +client := modelcontainer.NewModelContainerClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ModelContainerClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := modelcontainer.NewModelID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "modelName") + +payload := modelcontainer.ModelContainerResource{ + // ... +} + + +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: `ModelContainerClient.Delete` + +```go +ctx := context.TODO() +id := modelcontainer.NewModelID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "modelName") + +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: `ModelContainerClient.Get` + +```go +ctx := context.TODO() +id := modelcontainer.NewModelID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "modelName") + +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: `ModelContainerClient.List` + +```go +ctx := context.TODO() +id := modelcontainer.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +// alternatively `client.List(ctx, id, modelcontainer.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, modelcontainer.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ModelContainerClient.RegistryModelContainersCreateOrUpdate` + +```go +ctx := context.TODO() +id := modelcontainer.NewRegistryModelID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "modelName") + +payload := modelcontainer.ModelContainerResource{ + // ... +} + + +if err := client.RegistryModelContainersCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ModelContainerClient.RegistryModelContainersDelete` + +```go +ctx := context.TODO() +id := modelcontainer.NewRegistryModelID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "modelName") + +if err := client.RegistryModelContainersDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ModelContainerClient.RegistryModelContainersGet` + +```go +ctx := context.TODO() +id := modelcontainer.NewRegistryModelID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "modelName") + +read, err := client.RegistryModelContainersGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ModelContainerClient.RegistryModelContainersList` + +```go +ctx := context.TODO() +id := modelcontainer.NewRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName") + +// alternatively `client.RegistryModelContainersList(ctx, id, modelcontainer.DefaultRegistryModelContainersListOperationOptions())` can be used to do batched pagination +items, err := client.RegistryModelContainersListComplete(ctx, id, modelcontainer.DefaultRegistryModelContainersListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/modelcontainer/client.go b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/client.go new file mode 100644 index 00000000000..3404b406aa0 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/client.go @@ -0,0 +1,26 @@ +package modelcontainer + +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 ModelContainerClient struct { + Client *resourcemanager.Client +} + +func NewModelContainerClientWithBaseURI(sdkApi sdkEnv.Api) (*ModelContainerClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "modelcontainer", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ModelContainerClient: %+v", err) + } + + return &ModelContainerClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelcontainer/constants.go b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/constants.go new file mode 100644 index 00000000000..ee192f71a97 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/constants.go @@ -0,0 +1,107 @@ +package modelcontainer + +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 AssetProvisioningState string + +const ( + AssetProvisioningStateCanceled AssetProvisioningState = "Canceled" + AssetProvisioningStateCreating AssetProvisioningState = "Creating" + AssetProvisioningStateDeleting AssetProvisioningState = "Deleting" + AssetProvisioningStateFailed AssetProvisioningState = "Failed" + AssetProvisioningStateSucceeded AssetProvisioningState = "Succeeded" + AssetProvisioningStateUpdating AssetProvisioningState = "Updating" +) + +func PossibleValuesForAssetProvisioningState() []string { + return []string{ + string(AssetProvisioningStateCanceled), + string(AssetProvisioningStateCreating), + string(AssetProvisioningStateDeleting), + string(AssetProvisioningStateFailed), + string(AssetProvisioningStateSucceeded), + string(AssetProvisioningStateUpdating), + } +} + +func (s *AssetProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAssetProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAssetProvisioningState(input string) (*AssetProvisioningState, error) { + vals := map[string]AssetProvisioningState{ + "canceled": AssetProvisioningStateCanceled, + "creating": AssetProvisioningStateCreating, + "deleting": AssetProvisioningStateDeleting, + "failed": AssetProvisioningStateFailed, + "succeeded": AssetProvisioningStateSucceeded, + "updating": AssetProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AssetProvisioningState(input) + return &out, nil +} + +type ListViewType string + +const ( + ListViewTypeActiveOnly ListViewType = "ActiveOnly" + ListViewTypeAll ListViewType = "All" + ListViewTypeArchivedOnly ListViewType = "ArchivedOnly" +) + +func PossibleValuesForListViewType() []string { + return []string{ + string(ListViewTypeActiveOnly), + string(ListViewTypeAll), + string(ListViewTypeArchivedOnly), + } +} + +func (s *ListViewType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseListViewType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseListViewType(input string) (*ListViewType, error) { + vals := map[string]ListViewType{ + "activeonly": ListViewTypeActiveOnly, + "all": ListViewTypeAll, + "archivedonly": ListViewTypeArchivedOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ListViewType(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelcontainer/id_model.go b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/id_model.go new file mode 100644 index 00000000000..02e2f9da703 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/id_model.go @@ -0,0 +1,139 @@ +package modelcontainer + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ModelId{}) +} + +var _ resourceids.ResourceId = &ModelId{} + +// ModelId is a struct representing the Resource ID for a Model +type ModelId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + ModelName string +} + +// NewModelID returns a new ModelId struct +func NewModelID(subscriptionId string, resourceGroupName string, workspaceName string, modelName string) ModelId { + return ModelId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + ModelName: modelName, + } +} + +// ParseModelID parses 'input' into a ModelId +func ParseModelID(input string) (*ModelId, error) { + parser := resourceids.NewParserFromResourceIdType(&ModelId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ModelId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseModelIDInsensitively parses 'input' case-insensitively into a ModelId +// note: this method should only be used for API response data and not user input +func ParseModelIDInsensitively(input string) (*ModelId, error) { + parser := resourceids.NewParserFromResourceIdType(&ModelId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ModelId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ModelId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.ModelName, ok = input.Parsed["modelName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "modelName", input) + } + + return nil +} + +// ValidateModelID checks that 'input' can be parsed as a Model ID +func ValidateModelID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseModelID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Model ID +func (id ModelId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/models/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.ModelName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Model ID +func (id ModelId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticModels", "models", "models"), + resourceids.UserSpecifiedSegment("modelName", "modelName"), + } +} + +// String returns a human-readable description of this Model ID +func (id ModelId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Model Name: %q", id.ModelName), + } + return fmt.Sprintf("Model (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelcontainer/id_model_test.go b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/id_model_test.go new file mode 100644 index 00000000000..017d0116d1a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/id_model_test.go @@ -0,0 +1,327 @@ +package modelcontainer + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ModelId{} + +func TestNewModelID(t *testing.T) { + id := NewModelID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "modelName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.ModelName != "modelName" { + t.Fatalf("Expected %q but got %q for Segment 'ModelName'", id.ModelName, "modelName") + } +} + +func TestFormatModelID(t *testing.T) { + actual := NewModelID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "modelName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/models/modelName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseModelID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ModelId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/models", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/models/modelName", + Expected: &ModelId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + ModelName: "modelName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/models/modelName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseModelID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.ModelName != v.Expected.ModelName { + t.Fatalf("Expected %q but got %q for ModelName", v.Expected.ModelName, actual.ModelName) + } + + } +} + +func TestParseModelIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ModelId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/models", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/mOdElS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/models/modelName", + Expected: &ModelId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + ModelName: "modelName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/models/modelName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/mOdElS/mOdElNaMe", + Expected: &ModelId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + ModelName: "mOdElNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/mOdElS/mOdElNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseModelIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.ModelName != v.Expected.ModelName { + t.Fatalf("Expected %q but got %q for ModelName", v.Expected.ModelName, actual.ModelName) + } + + } +} + +func TestSegmentsForModelId(t *testing.T) { + segments := ModelId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ModelId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelcontainer/id_registry.go b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/id_registry.go new file mode 100644 index 00000000000..11d805a8d1e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/id_registry.go @@ -0,0 +1,130 @@ +package modelcontainer + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RegistryId{}) +} + +var _ resourceids.ResourceId = &RegistryId{} + +// RegistryId is a struct representing the Resource ID for a Registry +type RegistryId struct { + SubscriptionId string + ResourceGroupName string + RegistryName string +} + +// NewRegistryID returns a new RegistryId struct +func NewRegistryID(subscriptionId string, resourceGroupName string, registryName string) RegistryId { + return RegistryId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RegistryName: registryName, + } +} + +// ParseRegistryID parses 'input' into a RegistryId +func ParseRegistryID(input string) (*RegistryId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRegistryIDInsensitively parses 'input' case-insensitively into a RegistryId +// note: this method should only be used for API response data and not user input +func ParseRegistryIDInsensitively(input string) (*RegistryId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RegistryId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RegistryName, ok = input.Parsed["registryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "registryName", input) + } + + return nil +} + +// ValidateRegistryID checks that 'input' can be parsed as a Registry ID +func ValidateRegistryID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRegistryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Registry ID +func (id RegistryId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/registries/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RegistryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Registry ID +func (id RegistryId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticRegistries", "registries", "registries"), + resourceids.UserSpecifiedSegment("registryName", "registryName"), + } +} + +// String returns a human-readable description of this Registry ID +func (id RegistryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Registry Name: %q", id.RegistryName), + } + return fmt.Sprintf("Registry (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelcontainer/id_registry_test.go b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/id_registry_test.go new file mode 100644 index 00000000000..cc15e40faca --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/id_registry_test.go @@ -0,0 +1,282 @@ +package modelcontainer + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RegistryId{} + +func TestNewRegistryID(t *testing.T) { + id := NewRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RegistryName != "registryName" { + t.Fatalf("Expected %q but got %q for Segment 'RegistryName'", id.RegistryName, "registryName") + } +} + +func TestFormatRegistryID(t *testing.T) { + actual := NewRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRegistryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Expected: &RegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + } +} + +func TestParseRegistryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Expected: &RegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE", + Expected: &RegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RegistryName: "rEgIsTrYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + } +} + +func TestSegmentsForRegistryId(t *testing.T) { + segments := RegistryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RegistryId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelcontainer/id_registrymodel.go b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/id_registrymodel.go new file mode 100644 index 00000000000..b3c6e83d3ee --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/id_registrymodel.go @@ -0,0 +1,139 @@ +package modelcontainer + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RegistryModelId{}) +} + +var _ resourceids.ResourceId = &RegistryModelId{} + +// RegistryModelId is a struct representing the Resource ID for a Registry Model +type RegistryModelId struct { + SubscriptionId string + ResourceGroupName string + RegistryName string + ModelName string +} + +// NewRegistryModelID returns a new RegistryModelId struct +func NewRegistryModelID(subscriptionId string, resourceGroupName string, registryName string, modelName string) RegistryModelId { + return RegistryModelId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RegistryName: registryName, + ModelName: modelName, + } +} + +// ParseRegistryModelID parses 'input' into a RegistryModelId +func ParseRegistryModelID(input string) (*RegistryModelId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryModelId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryModelId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRegistryModelIDInsensitively parses 'input' case-insensitively into a RegistryModelId +// note: this method should only be used for API response data and not user input +func ParseRegistryModelIDInsensitively(input string) (*RegistryModelId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryModelId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryModelId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RegistryModelId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RegistryName, ok = input.Parsed["registryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "registryName", input) + } + + if id.ModelName, ok = input.Parsed["modelName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "modelName", input) + } + + return nil +} + +// ValidateRegistryModelID checks that 'input' can be parsed as a Registry Model ID +func ValidateRegistryModelID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRegistryModelID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Registry Model ID +func (id RegistryModelId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/registries/%s/models/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RegistryName, id.ModelName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Registry Model ID +func (id RegistryModelId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticRegistries", "registries", "registries"), + resourceids.UserSpecifiedSegment("registryName", "registryName"), + resourceids.StaticSegment("staticModels", "models", "models"), + resourceids.UserSpecifiedSegment("modelName", "modelName"), + } +} + +// String returns a human-readable description of this Registry Model ID +func (id RegistryModelId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Registry Name: %q", id.RegistryName), + fmt.Sprintf("Model Name: %q", id.ModelName), + } + return fmt.Sprintf("Registry Model (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelcontainer/id_registrymodel_test.go b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/id_registrymodel_test.go new file mode 100644 index 00000000000..f192428daa9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/id_registrymodel_test.go @@ -0,0 +1,327 @@ +package modelcontainer + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RegistryModelId{} + +func TestNewRegistryModelID(t *testing.T) { + id := NewRegistryModelID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "modelName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RegistryName != "registryName" { + t.Fatalf("Expected %q but got %q for Segment 'RegistryName'", id.RegistryName, "registryName") + } + + if id.ModelName != "modelName" { + t.Fatalf("Expected %q but got %q for Segment 'ModelName'", id.ModelName, "modelName") + } +} + +func TestFormatRegistryModelID(t *testing.T) { + actual := NewRegistryModelID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "modelName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/models/modelName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRegistryModelID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryModelId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/models", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/models/modelName", + Expected: &RegistryModelId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + ModelName: "modelName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/models/modelName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryModelID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.ModelName != v.Expected.ModelName { + t.Fatalf("Expected %q but got %q for ModelName", v.Expected.ModelName, actual.ModelName) + } + + } +} + +func TestParseRegistryModelIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryModelId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/models", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/mOdElS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/models/modelName", + Expected: &RegistryModelId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + ModelName: "modelName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/models/modelName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/mOdElS/mOdElNaMe", + Expected: &RegistryModelId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RegistryName: "rEgIsTrYnAmE", + ModelName: "mOdElNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/mOdElS/mOdElNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryModelIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.ModelName != v.Expected.ModelName { + t.Fatalf("Expected %q but got %q for ModelName", v.Expected.ModelName, actual.ModelName) + } + + } +} + +func TestSegmentsForRegistryModelId(t *testing.T) { + segments := RegistryModelId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RegistryModelId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelcontainer/id_workspace.go b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/id_workspace.go new file mode 100644 index 00000000000..88742fab8b1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/id_workspace.go @@ -0,0 +1,130 @@ +package modelcontainer + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelcontainer/id_workspace_test.go b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/id_workspace_test.go new file mode 100644 index 00000000000..34408f4eed5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/id_workspace_test.go @@ -0,0 +1,282 @@ +package modelcontainer + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelcontainer/method_createorupdate.go b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/method_createorupdate.go new file mode 100644 index 00000000000..e1041569d1c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/method_createorupdate.go @@ -0,0 +1,58 @@ +package modelcontainer + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ModelContainerResource +} + +// CreateOrUpdate ... +func (c ModelContainerClient) CreateOrUpdate(ctx context.Context, id ModelId, input ModelContainerResource) (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 ModelContainerResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelcontainer/method_delete.go b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/method_delete.go new file mode 100644 index 00000000000..f18ca796f48 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/method_delete.go @@ -0,0 +1,47 @@ +package modelcontainer + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 ModelContainerClient) Delete(ctx context.Context, id ModelId) (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/machinelearningservices/2025-04-01/modelcontainer/method_get.go b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/method_get.go new file mode 100644 index 00000000000..66adb267096 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/method_get.go @@ -0,0 +1,53 @@ +package modelcontainer + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ModelContainerResource +} + +// Get ... +func (c ModelContainerClient) Get(ctx context.Context, id ModelId) (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 ModelContainerResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelcontainer/method_list.go b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/method_list.go new file mode 100644 index 00000000000..2eaced29d85 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/method_list.go @@ -0,0 +1,142 @@ +package modelcontainer + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]ModelContainerResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ModelContainerResource +} + +type ListOperationOptions struct { + Count *int64 + ListViewType *ListViewType + Skip *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.Count != nil { + out.Append("count", fmt.Sprintf("%v", *o.Count)) + } + if o.ListViewType != nil { + out.Append("listViewType", fmt.Sprintf("%v", *o.ListViewType)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + 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 ModelContainerClient) List(ctx context.Context, id WorkspaceId, 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/models", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ModelContainerResource `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 ModelContainerClient) ListComplete(ctx context.Context, id WorkspaceId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ModelContainerResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ModelContainerClient) ListCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, options ListOperationOptions, predicate ModelContainerResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ModelContainerResource, 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/machinelearningservices/2025-04-01/modelcontainer/method_registrymodelcontainerscreateorupdate.go b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/method_registrymodelcontainerscreateorupdate.go new file mode 100644 index 00000000000..10288ec5157 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/method_registrymodelcontainerscreateorupdate.go @@ -0,0 +1,75 @@ +package modelcontainer + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryModelContainersCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ModelContainerResource +} + +// RegistryModelContainersCreateOrUpdate ... +func (c ModelContainerClient) RegistryModelContainersCreateOrUpdate(ctx context.Context, id RegistryModelId, input ModelContainerResource) (result RegistryModelContainersCreateOrUpdateOperationResponse, 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 +} + +// RegistryModelContainersCreateOrUpdateThenPoll performs RegistryModelContainersCreateOrUpdate then polls until it's completed +func (c ModelContainerClient) RegistryModelContainersCreateOrUpdateThenPoll(ctx context.Context, id RegistryModelId, input ModelContainerResource) error { + result, err := c.RegistryModelContainersCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RegistryModelContainersCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegistryModelContainersCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelcontainer/method_registrymodelcontainersdelete.go b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/method_registrymodelcontainersdelete.go new file mode 100644 index 00000000000..1026e78a544 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/method_registrymodelcontainersdelete.go @@ -0,0 +1,71 @@ +package modelcontainer + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryModelContainersDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RegistryModelContainersDelete ... +func (c ModelContainerClient) RegistryModelContainersDelete(ctx context.Context, id RegistryModelId) (result RegistryModelContainersDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RegistryModelContainersDeleteThenPoll performs RegistryModelContainersDelete then polls until it's completed +func (c ModelContainerClient) RegistryModelContainersDeleteThenPoll(ctx context.Context, id RegistryModelId) error { + result, err := c.RegistryModelContainersDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing RegistryModelContainersDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegistryModelContainersDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelcontainer/method_registrymodelcontainersget.go b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/method_registrymodelcontainersget.go new file mode 100644 index 00000000000..d8458035545 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/method_registrymodelcontainersget.go @@ -0,0 +1,53 @@ +package modelcontainer + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryModelContainersGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ModelContainerResource +} + +// RegistryModelContainersGet ... +func (c ModelContainerClient) RegistryModelContainersGet(ctx context.Context, id RegistryModelId) (result RegistryModelContainersGetOperationResponse, 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 ModelContainerResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelcontainer/method_registrymodelcontainerslist.go b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/method_registrymodelcontainerslist.go new file mode 100644 index 00000000000..d01d18bbd84 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/method_registrymodelcontainerslist.go @@ -0,0 +1,138 @@ +package modelcontainer + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryModelContainersListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ModelContainerResource +} + +type RegistryModelContainersListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ModelContainerResource +} + +type RegistryModelContainersListOperationOptions struct { + ListViewType *ListViewType + Skip *string +} + +func DefaultRegistryModelContainersListOperationOptions() RegistryModelContainersListOperationOptions { + return RegistryModelContainersListOperationOptions{} +} + +func (o RegistryModelContainersListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RegistryModelContainersListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RegistryModelContainersListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ListViewType != nil { + out.Append("listViewType", fmt.Sprintf("%v", *o.ListViewType)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + return &out +} + +type RegistryModelContainersListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *RegistryModelContainersListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// RegistryModelContainersList ... +func (c ModelContainerClient) RegistryModelContainersList(ctx context.Context, id RegistryId, options RegistryModelContainersListOperationOptions) (result RegistryModelContainersListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &RegistryModelContainersListCustomPager{}, + Path: fmt.Sprintf("%s/models", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ModelContainerResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RegistryModelContainersListComplete retrieves all the results into a single object +func (c ModelContainerClient) RegistryModelContainersListComplete(ctx context.Context, id RegistryId, options RegistryModelContainersListOperationOptions) (RegistryModelContainersListCompleteResult, error) { + return c.RegistryModelContainersListCompleteMatchingPredicate(ctx, id, options, ModelContainerResourceOperationPredicate{}) +} + +// RegistryModelContainersListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ModelContainerClient) RegistryModelContainersListCompleteMatchingPredicate(ctx context.Context, id RegistryId, options RegistryModelContainersListOperationOptions, predicate ModelContainerResourceOperationPredicate) (result RegistryModelContainersListCompleteResult, err error) { + items := make([]ModelContainerResource, 0) + + resp, err := c.RegistryModelContainersList(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 = RegistryModelContainersListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelcontainer/model_modelcontainer.go b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/model_modelcontainer.go new file mode 100644 index 00000000000..34d13fe5d70 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/model_modelcontainer.go @@ -0,0 +1,14 @@ +package modelcontainer + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ModelContainer struct { + Description *string `json:"description,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + LatestVersion *string `json:"latestVersion,omitempty"` + NextVersion *string `json:"nextVersion,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ProvisioningState *AssetProvisioningState `json:"provisioningState,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelcontainer/model_modelcontainerresource.go b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/model_modelcontainerresource.go new file mode 100644 index 00000000000..bda1030dd38 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/model_modelcontainerresource.go @@ -0,0 +1,16 @@ +package modelcontainer + +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 ModelContainerResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties ModelContainer `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelcontainer/predicates.go b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/predicates.go new file mode 100644 index 00000000000..1d70bbda11b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/predicates.go @@ -0,0 +1,27 @@ +package modelcontainer + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ModelContainerResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ModelContainerResourceOperationPredicate) Matches(input ModelContainerResource) 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/machinelearningservices/2025-04-01/modelcontainer/version.go b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/version.go new file mode 100644 index 00000000000..0e0421246ff --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelcontainer/version.go @@ -0,0 +1,10 @@ +package modelcontainer + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/modelcontainer/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/README.md b/resource-manager/machinelearningservices/2025-04-01/modelversion/README.md new file mode 100644 index 00000000000..0eb50882fac --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/README.md @@ -0,0 +1,190 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/modelversion` Documentation + +The `modelversion` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/modelversion" +``` + + +### Client Initialization + +```go +client := modelversion.NewModelVersionClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ModelVersionClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := modelversion.NewModelVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "modelName", "versionName") + +payload := modelversion.ModelVersionResource{ + // ... +} + + +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: `ModelVersionClient.Delete` + +```go +ctx := context.TODO() +id := modelversion.NewModelVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "modelName", "versionName") + +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: `ModelVersionClient.Get` + +```go +ctx := context.TODO() +id := modelversion.NewModelVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "modelName", "versionName") + +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: `ModelVersionClient.List` + +```go +ctx := context.TODO() +id := modelversion.NewModelID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "modelName") + +// alternatively `client.List(ctx, id, modelversion.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, modelversion.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ModelVersionClient.Publish` + +```go +ctx := context.TODO() +id := modelversion.NewModelVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "modelName", "versionName") + +payload := modelversion.DestinationAsset{ + // ... +} + + +if err := client.PublishThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ModelVersionClient.RegistryModelVersionsCreateOrGetStartPendingUpload` + +```go +ctx := context.TODO() +id := modelversion.NewRegistryModelVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "modelName", "versionName") + +payload := modelversion.PendingUploadRequestDto{ + // ... +} + + +read, err := client.RegistryModelVersionsCreateOrGetStartPendingUpload(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ModelVersionClient.RegistryModelVersionsCreateOrUpdate` + +```go +ctx := context.TODO() +id := modelversion.NewRegistryModelVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "modelName", "versionName") + +payload := modelversion.ModelVersionResource{ + // ... +} + + +if err := client.RegistryModelVersionsCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ModelVersionClient.RegistryModelVersionsDelete` + +```go +ctx := context.TODO() +id := modelversion.NewRegistryModelVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "modelName", "versionName") + +if err := client.RegistryModelVersionsDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ModelVersionClient.RegistryModelVersionsGet` + +```go +ctx := context.TODO() +id := modelversion.NewRegistryModelVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "modelName", "versionName") + +read, err := client.RegistryModelVersionsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ModelVersionClient.RegistryModelVersionsList` + +```go +ctx := context.TODO() +id := modelversion.NewRegistryModelID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "modelName") + +// alternatively `client.RegistryModelVersionsList(ctx, id, modelversion.DefaultRegistryModelVersionsListOperationOptions())` can be used to do batched pagination +items, err := client.RegistryModelVersionsListComplete(ctx, id, modelversion.DefaultRegistryModelVersionsListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/client.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/client.go new file mode 100644 index 00000000000..f2b5e5fa8c2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/client.go @@ -0,0 +1,26 @@ +package modelversion + +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 ModelVersionClient struct { + Client *resourcemanager.Client +} + +func NewModelVersionClientWithBaseURI(sdkApi sdkEnv.Api) (*ModelVersionClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "modelversion", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ModelVersionClient: %+v", err) + } + + return &ModelVersionClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/constants.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/constants.go new file mode 100644 index 00000000000..9b74f796d71 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/constants.go @@ -0,0 +1,186 @@ +package modelversion + +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 AssetProvisioningState string + +const ( + AssetProvisioningStateCanceled AssetProvisioningState = "Canceled" + AssetProvisioningStateCreating AssetProvisioningState = "Creating" + AssetProvisioningStateDeleting AssetProvisioningState = "Deleting" + AssetProvisioningStateFailed AssetProvisioningState = "Failed" + AssetProvisioningStateSucceeded AssetProvisioningState = "Succeeded" + AssetProvisioningStateUpdating AssetProvisioningState = "Updating" +) + +func PossibleValuesForAssetProvisioningState() []string { + return []string{ + string(AssetProvisioningStateCanceled), + string(AssetProvisioningStateCreating), + string(AssetProvisioningStateDeleting), + string(AssetProvisioningStateFailed), + string(AssetProvisioningStateSucceeded), + string(AssetProvisioningStateUpdating), + } +} + +func (s *AssetProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAssetProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAssetProvisioningState(input string) (*AssetProvisioningState, error) { + vals := map[string]AssetProvisioningState{ + "canceled": AssetProvisioningStateCanceled, + "creating": AssetProvisioningStateCreating, + "deleting": AssetProvisioningStateDeleting, + "failed": AssetProvisioningStateFailed, + "succeeded": AssetProvisioningStateSucceeded, + "updating": AssetProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AssetProvisioningState(input) + return &out, nil +} + +type ListViewType string + +const ( + ListViewTypeActiveOnly ListViewType = "ActiveOnly" + ListViewTypeAll ListViewType = "All" + ListViewTypeArchivedOnly ListViewType = "ArchivedOnly" +) + +func PossibleValuesForListViewType() []string { + return []string{ + string(ListViewTypeActiveOnly), + string(ListViewTypeAll), + string(ListViewTypeArchivedOnly), + } +} + +func (s *ListViewType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseListViewType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseListViewType(input string) (*ListViewType, error) { + vals := map[string]ListViewType{ + "activeonly": ListViewTypeActiveOnly, + "all": ListViewTypeAll, + "archivedonly": ListViewTypeArchivedOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ListViewType(input) + return &out, nil +} + +type PendingUploadCredentialType string + +const ( + PendingUploadCredentialTypeSAS PendingUploadCredentialType = "SAS" +) + +func PossibleValuesForPendingUploadCredentialType() []string { + return []string{ + string(PendingUploadCredentialTypeSAS), + } +} + +func (s *PendingUploadCredentialType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePendingUploadCredentialType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePendingUploadCredentialType(input string) (*PendingUploadCredentialType, error) { + vals := map[string]PendingUploadCredentialType{ + "sas": PendingUploadCredentialTypeSAS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PendingUploadCredentialType(input) + return &out, nil +} + +type PendingUploadType string + +const ( + PendingUploadTypeNone PendingUploadType = "None" + PendingUploadTypeTemporaryBlobReference PendingUploadType = "TemporaryBlobReference" +) + +func PossibleValuesForPendingUploadType() []string { + return []string{ + string(PendingUploadTypeNone), + string(PendingUploadTypeTemporaryBlobReference), + } +} + +func (s *PendingUploadType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePendingUploadType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePendingUploadType(input string) (*PendingUploadType, error) { + vals := map[string]PendingUploadType{ + "none": PendingUploadTypeNone, + "temporaryblobreference": PendingUploadTypeTemporaryBlobReference, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PendingUploadType(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/id_model.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/id_model.go new file mode 100644 index 00000000000..80b17552f6f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/id_model.go @@ -0,0 +1,139 @@ +package modelversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ModelId{}) +} + +var _ resourceids.ResourceId = &ModelId{} + +// ModelId is a struct representing the Resource ID for a Model +type ModelId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + ModelName string +} + +// NewModelID returns a new ModelId struct +func NewModelID(subscriptionId string, resourceGroupName string, workspaceName string, modelName string) ModelId { + return ModelId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + ModelName: modelName, + } +} + +// ParseModelID parses 'input' into a ModelId +func ParseModelID(input string) (*ModelId, error) { + parser := resourceids.NewParserFromResourceIdType(&ModelId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ModelId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseModelIDInsensitively parses 'input' case-insensitively into a ModelId +// note: this method should only be used for API response data and not user input +func ParseModelIDInsensitively(input string) (*ModelId, error) { + parser := resourceids.NewParserFromResourceIdType(&ModelId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ModelId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ModelId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.ModelName, ok = input.Parsed["modelName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "modelName", input) + } + + return nil +} + +// ValidateModelID checks that 'input' can be parsed as a Model ID +func ValidateModelID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseModelID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Model ID +func (id ModelId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/models/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.ModelName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Model ID +func (id ModelId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticModels", "models", "models"), + resourceids.UserSpecifiedSegment("modelName", "modelName"), + } +} + +// String returns a human-readable description of this Model ID +func (id ModelId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Model Name: %q", id.ModelName), + } + return fmt.Sprintf("Model (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/id_model_test.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/id_model_test.go new file mode 100644 index 00000000000..1c10ef24e95 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/id_model_test.go @@ -0,0 +1,327 @@ +package modelversion + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ModelId{} + +func TestNewModelID(t *testing.T) { + id := NewModelID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "modelName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.ModelName != "modelName" { + t.Fatalf("Expected %q but got %q for Segment 'ModelName'", id.ModelName, "modelName") + } +} + +func TestFormatModelID(t *testing.T) { + actual := NewModelID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "modelName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/models/modelName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseModelID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ModelId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/models", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/models/modelName", + Expected: &ModelId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + ModelName: "modelName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/models/modelName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseModelID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.ModelName != v.Expected.ModelName { + t.Fatalf("Expected %q but got %q for ModelName", v.Expected.ModelName, actual.ModelName) + } + + } +} + +func TestParseModelIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ModelId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/models", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/mOdElS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/models/modelName", + Expected: &ModelId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + ModelName: "modelName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/models/modelName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/mOdElS/mOdElNaMe", + Expected: &ModelId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + ModelName: "mOdElNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/mOdElS/mOdElNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseModelIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.ModelName != v.Expected.ModelName { + t.Fatalf("Expected %q but got %q for ModelName", v.Expected.ModelName, actual.ModelName) + } + + } +} + +func TestSegmentsForModelId(t *testing.T) { + segments := ModelId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ModelId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/id_modelversion.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/id_modelversion.go new file mode 100644 index 00000000000..a2539016486 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/id_modelversion.go @@ -0,0 +1,148 @@ +package modelversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ModelVersionId{}) +} + +var _ resourceids.ResourceId = &ModelVersionId{} + +// ModelVersionId is a struct representing the Resource ID for a Model Version +type ModelVersionId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + ModelName string + VersionName string +} + +// NewModelVersionID returns a new ModelVersionId struct +func NewModelVersionID(subscriptionId string, resourceGroupName string, workspaceName string, modelName string, versionName string) ModelVersionId { + return ModelVersionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + ModelName: modelName, + VersionName: versionName, + } +} + +// ParseModelVersionID parses 'input' into a ModelVersionId +func ParseModelVersionID(input string) (*ModelVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ModelVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ModelVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseModelVersionIDInsensitively parses 'input' case-insensitively into a ModelVersionId +// note: this method should only be used for API response data and not user input +func ParseModelVersionIDInsensitively(input string) (*ModelVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ModelVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ModelVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ModelVersionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.ModelName, ok = input.Parsed["modelName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "modelName", input) + } + + if id.VersionName, ok = input.Parsed["versionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "versionName", input) + } + + return nil +} + +// ValidateModelVersionID checks that 'input' can be parsed as a Model Version ID +func ValidateModelVersionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseModelVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Model Version ID +func (id ModelVersionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/models/%s/versions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.ModelName, id.VersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Model Version ID +func (id ModelVersionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticModels", "models", "models"), + resourceids.UserSpecifiedSegment("modelName", "modelName"), + resourceids.StaticSegment("staticVersions", "versions", "versions"), + resourceids.UserSpecifiedSegment("versionName", "versionName"), + } +} + +// String returns a human-readable description of this Model Version ID +func (id ModelVersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Model Name: %q", id.ModelName), + fmt.Sprintf("Version Name: %q", id.VersionName), + } + return fmt.Sprintf("Model Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/id_modelversion_test.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/id_modelversion_test.go new file mode 100644 index 00000000000..ed52275cff8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/id_modelversion_test.go @@ -0,0 +1,372 @@ +package modelversion + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ModelVersionId{} + +func TestNewModelVersionID(t *testing.T) { + id := NewModelVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "modelName", "versionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.ModelName != "modelName" { + t.Fatalf("Expected %q but got %q for Segment 'ModelName'", id.ModelName, "modelName") + } + + if id.VersionName != "versionName" { + t.Fatalf("Expected %q but got %q for Segment 'VersionName'", id.VersionName, "versionName") + } +} + +func TestFormatModelVersionID(t *testing.T) { + actual := NewModelVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "modelName", "versionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/models/modelName/versions/versionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseModelVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ModelVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/models", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/models/modelName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/models/modelName/versions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/models/modelName/versions/versionName", + Expected: &ModelVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + ModelName: "modelName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/models/modelName/versions/versionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseModelVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.ModelName != v.Expected.ModelName { + t.Fatalf("Expected %q but got %q for ModelName", v.Expected.ModelName, actual.ModelName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestParseModelVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ModelVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/models", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/mOdElS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/models/modelName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/mOdElS/mOdElNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/models/modelName/versions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/mOdElS/mOdElNaMe/vErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/models/modelName/versions/versionName", + Expected: &ModelVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + ModelName: "modelName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/models/modelName/versions/versionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/mOdElS/mOdElNaMe/vErSiOnS/vErSiOnNaMe", + Expected: &ModelVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + ModelName: "mOdElNaMe", + VersionName: "vErSiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/mOdElS/mOdElNaMe/vErSiOnS/vErSiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseModelVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.ModelName != v.Expected.ModelName { + t.Fatalf("Expected %q but got %q for ModelName", v.Expected.ModelName, actual.ModelName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestSegmentsForModelVersionId(t *testing.T) { + segments := ModelVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ModelVersionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/id_registrymodel.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/id_registrymodel.go new file mode 100644 index 00000000000..e93a72b7867 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/id_registrymodel.go @@ -0,0 +1,139 @@ +package modelversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RegistryModelId{}) +} + +var _ resourceids.ResourceId = &RegistryModelId{} + +// RegistryModelId is a struct representing the Resource ID for a Registry Model +type RegistryModelId struct { + SubscriptionId string + ResourceGroupName string + RegistryName string + ModelName string +} + +// NewRegistryModelID returns a new RegistryModelId struct +func NewRegistryModelID(subscriptionId string, resourceGroupName string, registryName string, modelName string) RegistryModelId { + return RegistryModelId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RegistryName: registryName, + ModelName: modelName, + } +} + +// ParseRegistryModelID parses 'input' into a RegistryModelId +func ParseRegistryModelID(input string) (*RegistryModelId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryModelId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryModelId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRegistryModelIDInsensitively parses 'input' case-insensitively into a RegistryModelId +// note: this method should only be used for API response data and not user input +func ParseRegistryModelIDInsensitively(input string) (*RegistryModelId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryModelId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryModelId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RegistryModelId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RegistryName, ok = input.Parsed["registryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "registryName", input) + } + + if id.ModelName, ok = input.Parsed["modelName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "modelName", input) + } + + return nil +} + +// ValidateRegistryModelID checks that 'input' can be parsed as a Registry Model ID +func ValidateRegistryModelID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRegistryModelID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Registry Model ID +func (id RegistryModelId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/registries/%s/models/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RegistryName, id.ModelName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Registry Model ID +func (id RegistryModelId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticRegistries", "registries", "registries"), + resourceids.UserSpecifiedSegment("registryName", "registryName"), + resourceids.StaticSegment("staticModels", "models", "models"), + resourceids.UserSpecifiedSegment("modelName", "modelName"), + } +} + +// String returns a human-readable description of this Registry Model ID +func (id RegistryModelId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Registry Name: %q", id.RegistryName), + fmt.Sprintf("Model Name: %q", id.ModelName), + } + return fmt.Sprintf("Registry Model (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/id_registrymodel_test.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/id_registrymodel_test.go new file mode 100644 index 00000000000..7e181cbc073 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/id_registrymodel_test.go @@ -0,0 +1,327 @@ +package modelversion + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RegistryModelId{} + +func TestNewRegistryModelID(t *testing.T) { + id := NewRegistryModelID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "modelName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RegistryName != "registryName" { + t.Fatalf("Expected %q but got %q for Segment 'RegistryName'", id.RegistryName, "registryName") + } + + if id.ModelName != "modelName" { + t.Fatalf("Expected %q but got %q for Segment 'ModelName'", id.ModelName, "modelName") + } +} + +func TestFormatRegistryModelID(t *testing.T) { + actual := NewRegistryModelID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "modelName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/models/modelName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRegistryModelID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryModelId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/models", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/models/modelName", + Expected: &RegistryModelId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + ModelName: "modelName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/models/modelName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryModelID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.ModelName != v.Expected.ModelName { + t.Fatalf("Expected %q but got %q for ModelName", v.Expected.ModelName, actual.ModelName) + } + + } +} + +func TestParseRegistryModelIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryModelId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/models", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/mOdElS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/models/modelName", + Expected: &RegistryModelId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + ModelName: "modelName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/models/modelName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/mOdElS/mOdElNaMe", + Expected: &RegistryModelId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RegistryName: "rEgIsTrYnAmE", + ModelName: "mOdElNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/mOdElS/mOdElNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryModelIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.ModelName != v.Expected.ModelName { + t.Fatalf("Expected %q but got %q for ModelName", v.Expected.ModelName, actual.ModelName) + } + + } +} + +func TestSegmentsForRegistryModelId(t *testing.T) { + segments := RegistryModelId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RegistryModelId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/id_registrymodelversion.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/id_registrymodelversion.go new file mode 100644 index 00000000000..44882f79336 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/id_registrymodelversion.go @@ -0,0 +1,148 @@ +package modelversion + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RegistryModelVersionId{}) +} + +var _ resourceids.ResourceId = &RegistryModelVersionId{} + +// RegistryModelVersionId is a struct representing the Resource ID for a Registry Model Version +type RegistryModelVersionId struct { + SubscriptionId string + ResourceGroupName string + RegistryName string + ModelName string + VersionName string +} + +// NewRegistryModelVersionID returns a new RegistryModelVersionId struct +func NewRegistryModelVersionID(subscriptionId string, resourceGroupName string, registryName string, modelName string, versionName string) RegistryModelVersionId { + return RegistryModelVersionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RegistryName: registryName, + ModelName: modelName, + VersionName: versionName, + } +} + +// ParseRegistryModelVersionID parses 'input' into a RegistryModelVersionId +func ParseRegistryModelVersionID(input string) (*RegistryModelVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryModelVersionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryModelVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRegistryModelVersionIDInsensitively parses 'input' case-insensitively into a RegistryModelVersionId +// note: this method should only be used for API response data and not user input +func ParseRegistryModelVersionIDInsensitively(input string) (*RegistryModelVersionId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryModelVersionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryModelVersionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RegistryModelVersionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RegistryName, ok = input.Parsed["registryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "registryName", input) + } + + if id.ModelName, ok = input.Parsed["modelName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "modelName", input) + } + + if id.VersionName, ok = input.Parsed["versionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "versionName", input) + } + + return nil +} + +// ValidateRegistryModelVersionID checks that 'input' can be parsed as a Registry Model Version ID +func ValidateRegistryModelVersionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRegistryModelVersionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Registry Model Version ID +func (id RegistryModelVersionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/registries/%s/models/%s/versions/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RegistryName, id.ModelName, id.VersionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Registry Model Version ID +func (id RegistryModelVersionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticRegistries", "registries", "registries"), + resourceids.UserSpecifiedSegment("registryName", "registryName"), + resourceids.StaticSegment("staticModels", "models", "models"), + resourceids.UserSpecifiedSegment("modelName", "modelName"), + resourceids.StaticSegment("staticVersions", "versions", "versions"), + resourceids.UserSpecifiedSegment("versionName", "versionName"), + } +} + +// String returns a human-readable description of this Registry Model Version ID +func (id RegistryModelVersionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Registry Name: %q", id.RegistryName), + fmt.Sprintf("Model Name: %q", id.ModelName), + fmt.Sprintf("Version Name: %q", id.VersionName), + } + return fmt.Sprintf("Registry Model Version (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/id_registrymodelversion_test.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/id_registrymodelversion_test.go new file mode 100644 index 00000000000..6cad867d5d9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/id_registrymodelversion_test.go @@ -0,0 +1,372 @@ +package modelversion + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RegistryModelVersionId{} + +func TestNewRegistryModelVersionID(t *testing.T) { + id := NewRegistryModelVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "modelName", "versionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RegistryName != "registryName" { + t.Fatalf("Expected %q but got %q for Segment 'RegistryName'", id.RegistryName, "registryName") + } + + if id.ModelName != "modelName" { + t.Fatalf("Expected %q but got %q for Segment 'ModelName'", id.ModelName, "modelName") + } + + if id.VersionName != "versionName" { + t.Fatalf("Expected %q but got %q for Segment 'VersionName'", id.VersionName, "versionName") + } +} + +func TestFormatRegistryModelVersionID(t *testing.T) { + actual := NewRegistryModelVersionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName", "modelName", "versionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/models/modelName/versions/versionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRegistryModelVersionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryModelVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/models", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/models/modelName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/models/modelName/versions", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/models/modelName/versions/versionName", + Expected: &RegistryModelVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + ModelName: "modelName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/models/modelName/versions/versionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryModelVersionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.ModelName != v.Expected.ModelName { + t.Fatalf("Expected %q but got %q for ModelName", v.Expected.ModelName, actual.ModelName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestParseRegistryModelVersionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryModelVersionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/models", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/mOdElS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/models/modelName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/mOdElS/mOdElNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/models/modelName/versions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/mOdElS/mOdElNaMe/vErSiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/models/modelName/versions/versionName", + Expected: &RegistryModelVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + ModelName: "modelName", + VersionName: "versionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/models/modelName/versions/versionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/mOdElS/mOdElNaMe/vErSiOnS/vErSiOnNaMe", + Expected: &RegistryModelVersionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RegistryName: "rEgIsTrYnAmE", + ModelName: "mOdElNaMe", + VersionName: "vErSiOnNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/mOdElS/mOdElNaMe/vErSiOnS/vErSiOnNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryModelVersionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + if actual.ModelName != v.Expected.ModelName { + t.Fatalf("Expected %q but got %q for ModelName", v.Expected.ModelName, actual.ModelName) + } + + if actual.VersionName != v.Expected.VersionName { + t.Fatalf("Expected %q but got %q for VersionName", v.Expected.VersionName, actual.VersionName) + } + + } +} + +func TestSegmentsForRegistryModelVersionId(t *testing.T) { + segments := RegistryModelVersionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RegistryModelVersionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/method_createorupdate.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/method_createorupdate.go new file mode 100644 index 00000000000..0f6670fb5dd --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/method_createorupdate.go @@ -0,0 +1,58 @@ +package modelversion + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ModelVersionResource +} + +// CreateOrUpdate ... +func (c ModelVersionClient) CreateOrUpdate(ctx context.Context, id ModelVersionId, input ModelVersionResource) (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 ModelVersionResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/method_delete.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/method_delete.go new file mode 100644 index 00000000000..18a2dbd7ea2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/method_delete.go @@ -0,0 +1,47 @@ +package modelversion + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 ModelVersionClient) Delete(ctx context.Context, id ModelVersionId) (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/machinelearningservices/2025-04-01/modelversion/method_get.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/method_get.go new file mode 100644 index 00000000000..4e318f7353e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/method_get.go @@ -0,0 +1,53 @@ +package modelversion + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ModelVersionResource +} + +// Get ... +func (c ModelVersionClient) Get(ctx context.Context, id ModelVersionId) (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 ModelVersionResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/method_list.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/method_list.go new file mode 100644 index 00000000000..11f72b9413b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/method_list.go @@ -0,0 +1,170 @@ +package modelversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]ModelVersionResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ModelVersionResource +} + +type ListOperationOptions struct { + Description *string + Feed *string + ListViewType *ListViewType + Offset *int64 + OrderBy *string + Properties *string + Skip *string + Tags *string + Top *int64 + Version *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.Description != nil { + out.Append("description", fmt.Sprintf("%v", *o.Description)) + } + if o.Feed != nil { + out.Append("feed", fmt.Sprintf("%v", *o.Feed)) + } + if o.ListViewType != nil { + out.Append("listViewType", fmt.Sprintf("%v", *o.ListViewType)) + } + if o.Offset != nil { + out.Append("offset", fmt.Sprintf("%v", *o.Offset)) + } + if o.OrderBy != nil { + out.Append("$orderBy", fmt.Sprintf("%v", *o.OrderBy)) + } + if o.Properties != nil { + out.Append("properties", fmt.Sprintf("%v", *o.Properties)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Tags != nil { + out.Append("tags", fmt.Sprintf("%v", *o.Tags)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + if o.Version != nil { + out.Append("version", fmt.Sprintf("%v", *o.Version)) + } + 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 ModelVersionClient) List(ctx context.Context, id ModelId, options ListOperationOptions) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListCustomPager{}, + Path: fmt.Sprintf("%s/versions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ModelVersionResource `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 ModelVersionClient) ListComplete(ctx context.Context, id ModelId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ModelVersionResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ModelVersionClient) ListCompleteMatchingPredicate(ctx context.Context, id ModelId, options ListOperationOptions, predicate ModelVersionResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ModelVersionResource, 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/machinelearningservices/2025-04-01/modelversion/method_publish.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/method_publish.go new file mode 100644 index 00000000000..16b1e94ab0b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/method_publish.go @@ -0,0 +1,74 @@ +package modelversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PublishOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// Publish ... +func (c ModelVersionClient) Publish(ctx context.Context, id ModelVersionId, input DestinationAsset) (result PublishOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/publish", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// PublishThenPoll performs Publish then polls until it's completed +func (c ModelVersionClient) PublishThenPoll(ctx context.Context, id ModelVersionId, input DestinationAsset) error { + result, err := c.Publish(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Publish: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Publish: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/method_registrymodelversionscreateorgetstartpendingupload.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/method_registrymodelversionscreateorgetstartpendingupload.go new file mode 100644 index 00000000000..c79401b3454 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/method_registrymodelversionscreateorgetstartpendingupload.go @@ -0,0 +1,58 @@ +package modelversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryModelVersionsCreateOrGetStartPendingUploadOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PendingUploadResponseDto +} + +// RegistryModelVersionsCreateOrGetStartPendingUpload ... +func (c ModelVersionClient) RegistryModelVersionsCreateOrGetStartPendingUpload(ctx context.Context, id RegistryModelVersionId, input PendingUploadRequestDto) (result RegistryModelVersionsCreateOrGetStartPendingUploadOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/startPendingUpload", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model PendingUploadResponseDto + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/method_registrymodelversionscreateorupdate.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/method_registrymodelversionscreateorupdate.go new file mode 100644 index 00000000000..b11d7efd208 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/method_registrymodelversionscreateorupdate.go @@ -0,0 +1,75 @@ +package modelversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryModelVersionsCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ModelVersionResource +} + +// RegistryModelVersionsCreateOrUpdate ... +func (c ModelVersionClient) RegistryModelVersionsCreateOrUpdate(ctx context.Context, id RegistryModelVersionId, input ModelVersionResource) (result RegistryModelVersionsCreateOrUpdateOperationResponse, 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 +} + +// RegistryModelVersionsCreateOrUpdateThenPoll performs RegistryModelVersionsCreateOrUpdate then polls until it's completed +func (c ModelVersionClient) RegistryModelVersionsCreateOrUpdateThenPoll(ctx context.Context, id RegistryModelVersionId, input ModelVersionResource) error { + result, err := c.RegistryModelVersionsCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RegistryModelVersionsCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegistryModelVersionsCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/method_registrymodelversionsdelete.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/method_registrymodelversionsdelete.go new file mode 100644 index 00000000000..e2c10c49141 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/method_registrymodelversionsdelete.go @@ -0,0 +1,71 @@ +package modelversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryModelVersionsDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RegistryModelVersionsDelete ... +func (c ModelVersionClient) RegistryModelVersionsDelete(ctx context.Context, id RegistryModelVersionId) (result RegistryModelVersionsDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RegistryModelVersionsDeleteThenPoll performs RegistryModelVersionsDelete then polls until it's completed +func (c ModelVersionClient) RegistryModelVersionsDeleteThenPoll(ctx context.Context, id RegistryModelVersionId) error { + result, err := c.RegistryModelVersionsDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing RegistryModelVersionsDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegistryModelVersionsDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/method_registrymodelversionsget.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/method_registrymodelversionsget.go new file mode 100644 index 00000000000..e0a77444a2f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/method_registrymodelversionsget.go @@ -0,0 +1,53 @@ +package modelversion + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryModelVersionsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ModelVersionResource +} + +// RegistryModelVersionsGet ... +func (c ModelVersionClient) RegistryModelVersionsGet(ctx context.Context, id RegistryModelVersionId) (result RegistryModelVersionsGetOperationResponse, 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 ModelVersionResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/method_registrymodelversionslist.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/method_registrymodelversionslist.go new file mode 100644 index 00000000000..38d74637469 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/method_registrymodelversionslist.go @@ -0,0 +1,162 @@ +package modelversion + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryModelVersionsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ModelVersionResource +} + +type RegistryModelVersionsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ModelVersionResource +} + +type RegistryModelVersionsListOperationOptions struct { + Description *string + ListViewType *ListViewType + OrderBy *string + Properties *string + Skip *string + Tags *string + Top *int64 + Version *string +} + +func DefaultRegistryModelVersionsListOperationOptions() RegistryModelVersionsListOperationOptions { + return RegistryModelVersionsListOperationOptions{} +} + +func (o RegistryModelVersionsListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o RegistryModelVersionsListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o RegistryModelVersionsListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Description != nil { + out.Append("description", fmt.Sprintf("%v", *o.Description)) + } + if o.ListViewType != nil { + out.Append("listViewType", fmt.Sprintf("%v", *o.ListViewType)) + } + if o.OrderBy != nil { + out.Append("$orderBy", fmt.Sprintf("%v", *o.OrderBy)) + } + if o.Properties != nil { + out.Append("properties", fmt.Sprintf("%v", *o.Properties)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Tags != nil { + out.Append("tags", fmt.Sprintf("%v", *o.Tags)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + if o.Version != nil { + out.Append("version", fmt.Sprintf("%v", *o.Version)) + } + return &out +} + +type RegistryModelVersionsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *RegistryModelVersionsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// RegistryModelVersionsList ... +func (c ModelVersionClient) RegistryModelVersionsList(ctx context.Context, id RegistryModelId, options RegistryModelVersionsListOperationOptions) (result RegistryModelVersionsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &RegistryModelVersionsListCustomPager{}, + Path: fmt.Sprintf("%s/versions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ModelVersionResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RegistryModelVersionsListComplete retrieves all the results into a single object +func (c ModelVersionClient) RegistryModelVersionsListComplete(ctx context.Context, id RegistryModelId, options RegistryModelVersionsListOperationOptions) (RegistryModelVersionsListCompleteResult, error) { + return c.RegistryModelVersionsListCompleteMatchingPredicate(ctx, id, options, ModelVersionResourceOperationPredicate{}) +} + +// RegistryModelVersionsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ModelVersionClient) RegistryModelVersionsListCompleteMatchingPredicate(ctx context.Context, id RegistryModelId, options RegistryModelVersionsListOperationOptions, predicate ModelVersionResourceOperationPredicate) (result RegistryModelVersionsListCompleteResult, err error) { + items := make([]ModelVersionResource, 0) + + resp, err := c.RegistryModelVersionsList(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 = RegistryModelVersionsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/model_blobreferenceforconsumptiondto.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/model_blobreferenceforconsumptiondto.go new file mode 100644 index 00000000000..edcb11eb309 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/model_blobreferenceforconsumptiondto.go @@ -0,0 +1,45 @@ +package modelversion + +import ( + "encoding/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 BlobReferenceForConsumptionDto struct { + BlobUri *string `json:"blobUri,omitempty"` + Credential PendingUploadCredentialDto `json:"credential"` + StorageAccountArmId *string `json:"storageAccountArmId,omitempty"` +} + +var _ json.Unmarshaler = &BlobReferenceForConsumptionDto{} + +func (s *BlobReferenceForConsumptionDto) UnmarshalJSON(bytes []byte) error { + var decoded struct { + BlobUri *string `json:"blobUri,omitempty"` + StorageAccountArmId *string `json:"storageAccountArmId,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.BlobUri = decoded.BlobUri + s.StorageAccountArmId = decoded.StorageAccountArmId + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling BlobReferenceForConsumptionDto into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["credential"]; ok { + impl, err := UnmarshalPendingUploadCredentialDtoImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Credential' for 'BlobReferenceForConsumptionDto': %+v", err) + } + s.Credential = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/model_destinationasset.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/model_destinationasset.go new file mode 100644 index 00000000000..56e0f6655a3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/model_destinationasset.go @@ -0,0 +1,10 @@ +package modelversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DestinationAsset struct { + DestinationName *string `json:"destinationName,omitempty"` + DestinationVersion *string `json:"destinationVersion,omitempty"` + RegistryName *string `json:"registryName,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/model_flavordata.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/model_flavordata.go new file mode 100644 index 00000000000..7666bfc35c4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/model_flavordata.go @@ -0,0 +1,8 @@ +package modelversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FlavorData struct { + Data *map[string]string `json:"data,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/model_modelversion.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/model_modelversion.go new file mode 100644 index 00000000000..61b5d52261d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/model_modelversion.go @@ -0,0 +1,18 @@ +package modelversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ModelVersion struct { + Description *string `json:"description,omitempty"` + Flavors *map[string]FlavorData `json:"flavors,omitempty"` + IsAnonymous *bool `json:"isAnonymous,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + JobName *string `json:"jobName,omitempty"` + ModelType *string `json:"modelType,omitempty"` + ModelUri *string `json:"modelUri,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ProvisioningState *AssetProvisioningState `json:"provisioningState,omitempty"` + Stage *string `json:"stage,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/model_modelversionresource.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/model_modelversionresource.go new file mode 100644 index 00000000000..7a34857dc23 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/model_modelversionresource.go @@ -0,0 +1,16 @@ +package modelversion + +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 ModelVersionResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties ModelVersion `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/model_pendinguploadcredentialdto.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/model_pendinguploadcredentialdto.go new file mode 100644 index 00000000000..2d355cecac1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/model_pendinguploadcredentialdto.go @@ -0,0 +1,75 @@ +package modelversion + +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 PendingUploadCredentialDto interface { + PendingUploadCredentialDto() BasePendingUploadCredentialDtoImpl +} + +var _ PendingUploadCredentialDto = BasePendingUploadCredentialDtoImpl{} + +type BasePendingUploadCredentialDtoImpl struct { + CredentialType PendingUploadCredentialType `json:"credentialType"` +} + +func (s BasePendingUploadCredentialDtoImpl) PendingUploadCredentialDto() BasePendingUploadCredentialDtoImpl { + return s +} + +var _ PendingUploadCredentialDto = RawPendingUploadCredentialDtoImpl{} + +// RawPendingUploadCredentialDtoImpl 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 RawPendingUploadCredentialDtoImpl struct { + pendingUploadCredentialDto BasePendingUploadCredentialDtoImpl + Type string + Values map[string]interface{} +} + +func (s RawPendingUploadCredentialDtoImpl) PendingUploadCredentialDto() BasePendingUploadCredentialDtoImpl { + return s.pendingUploadCredentialDto +} + +func UnmarshalPendingUploadCredentialDtoImplementation(input []byte) (PendingUploadCredentialDto, 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 PendingUploadCredentialDto into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["credentialType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "SAS") { + var out SASCredentialDto + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SASCredentialDto: %+v", err) + } + return out, nil + } + + var parent BasePendingUploadCredentialDtoImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BasePendingUploadCredentialDtoImpl: %+v", err) + } + + return RawPendingUploadCredentialDtoImpl{ + pendingUploadCredentialDto: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/model_pendinguploadrequestdto.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/model_pendinguploadrequestdto.go new file mode 100644 index 00000000000..c4a08330ccf --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/model_pendinguploadrequestdto.go @@ -0,0 +1,9 @@ +package modelversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PendingUploadRequestDto struct { + PendingUploadId *string `json:"pendingUploadId,omitempty"` + PendingUploadType *PendingUploadType `json:"pendingUploadType,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/model_pendinguploadresponsedto.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/model_pendinguploadresponsedto.go new file mode 100644 index 00000000000..54c75618173 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/model_pendinguploadresponsedto.go @@ -0,0 +1,10 @@ +package modelversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PendingUploadResponseDto struct { + BlobReferenceForConsumption *BlobReferenceForConsumptionDto `json:"blobReferenceForConsumption,omitempty"` + PendingUploadId *string `json:"pendingUploadId,omitempty"` + PendingUploadType *PendingUploadType `json:"pendingUploadType,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/model_sascredentialdto.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/model_sascredentialdto.go new file mode 100644 index 00000000000..1c8b88412fc --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/model_sascredentialdto.go @@ -0,0 +1,50 @@ +package modelversion + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PendingUploadCredentialDto = SASCredentialDto{} + +type SASCredentialDto struct { + SasUri *string `json:"sasUri,omitempty"` + + // Fields inherited from PendingUploadCredentialDto + + CredentialType PendingUploadCredentialType `json:"credentialType"` +} + +func (s SASCredentialDto) PendingUploadCredentialDto() BasePendingUploadCredentialDtoImpl { + return BasePendingUploadCredentialDtoImpl{ + CredentialType: s.CredentialType, + } +} + +var _ json.Marshaler = SASCredentialDto{} + +func (s SASCredentialDto) MarshalJSON() ([]byte, error) { + type wrapper SASCredentialDto + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SASCredentialDto: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SASCredentialDto: %+v", err) + } + + decoded["credentialType"] = "SAS" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SASCredentialDto: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/modelversion/predicates.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/predicates.go new file mode 100644 index 00000000000..5ce605e9db3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/predicates.go @@ -0,0 +1,27 @@ +package modelversion + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ModelVersionResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ModelVersionResourceOperationPredicate) Matches(input ModelVersionResource) 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/machinelearningservices/2025-04-01/modelversion/version.go b/resource-manager/machinelearningservices/2025-04-01/modelversion/version.go new file mode 100644 index 00000000000..9475724e0ee --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/modelversion/version.go @@ -0,0 +1,10 @@ +package modelversion + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/modelversion/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/README.md b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/README.md new file mode 100644 index 00000000000..3ca40733b9d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/README.md @@ -0,0 +1,137 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/onlinedeployment` Documentation + +The `onlinedeployment` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/onlinedeployment" +``` + + +### Client Initialization + +```go +client := onlinedeployment.NewOnlineDeploymentClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `OnlineDeploymentClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := onlinedeployment.NewOnlineEndpointDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "onlineEndpointName", "deploymentName") + +payload := onlinedeployment.OnlineDeploymentTrackedResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `OnlineDeploymentClient.Delete` + +```go +ctx := context.TODO() +id := onlinedeployment.NewOnlineEndpointDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "onlineEndpointName", "deploymentName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `OnlineDeploymentClient.Get` + +```go +ctx := context.TODO() +id := onlinedeployment.NewOnlineEndpointDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "onlineEndpointName", "deploymentName") + +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: `OnlineDeploymentClient.GetLogs` + +```go +ctx := context.TODO() +id := onlinedeployment.NewOnlineEndpointDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "onlineEndpointName", "deploymentName") + +payload := onlinedeployment.DeploymentLogsRequest{ + // ... +} + + +read, err := client.GetLogs(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `OnlineDeploymentClient.List` + +```go +ctx := context.TODO() +id := onlinedeployment.NewOnlineEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "onlineEndpointName") + +// alternatively `client.List(ctx, id, onlinedeployment.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, onlinedeployment.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `OnlineDeploymentClient.ListSkus` + +```go +ctx := context.TODO() +id := onlinedeployment.NewOnlineEndpointDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "onlineEndpointName", "deploymentName") + +// alternatively `client.ListSkus(ctx, id, onlinedeployment.DefaultListSkusOperationOptions())` can be used to do batched pagination +items, err := client.ListSkusComplete(ctx, id, onlinedeployment.DefaultListSkusOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `OnlineDeploymentClient.Update` + +```go +ctx := context.TODO() +id := onlinedeployment.NewOnlineEndpointDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "onlineEndpointName", "deploymentName") + +payload := onlinedeployment.PartialMinimalTrackedResourceWithSku{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/client.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/client.go new file mode 100644 index 00000000000..b89f27bf3fc --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/client.go @@ -0,0 +1,26 @@ +package onlinedeployment + +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 OnlineDeploymentClient struct { + Client *resourcemanager.Client +} + +func NewOnlineDeploymentClientWithBaseURI(sdkApi sdkEnv.Api) (*OnlineDeploymentClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "onlinedeployment", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating OnlineDeploymentClient: %+v", err) + } + + return &OnlineDeploymentClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/constants.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/constants.go new file mode 100644 index 00000000000..2ef0fec9746 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/constants.go @@ -0,0 +1,415 @@ +package onlinedeployment + +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 ContainerType string + +const ( + ContainerTypeInferenceServer ContainerType = "InferenceServer" + ContainerTypeStorageInitializer ContainerType = "StorageInitializer" +) + +func PossibleValuesForContainerType() []string { + return []string{ + string(ContainerTypeInferenceServer), + string(ContainerTypeStorageInitializer), + } +} + +func (s *ContainerType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseContainerType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseContainerType(input string) (*ContainerType, error) { + vals := map[string]ContainerType{ + "inferenceserver": ContainerTypeInferenceServer, + "storageinitializer": ContainerTypeStorageInitializer, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ContainerType(input) + return &out, nil +} + +type DataCollectionMode string + +const ( + DataCollectionModeDisabled DataCollectionMode = "Disabled" + DataCollectionModeEnabled DataCollectionMode = "Enabled" +) + +func PossibleValuesForDataCollectionMode() []string { + return []string{ + string(DataCollectionModeDisabled), + string(DataCollectionModeEnabled), + } +} + +func (s *DataCollectionMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDataCollectionMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDataCollectionMode(input string) (*DataCollectionMode, error) { + vals := map[string]DataCollectionMode{ + "disabled": DataCollectionModeDisabled, + "enabled": DataCollectionModeEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DataCollectionMode(input) + return &out, nil +} + +type DeploymentProvisioningState string + +const ( + DeploymentProvisioningStateCanceled DeploymentProvisioningState = "Canceled" + DeploymentProvisioningStateCreating DeploymentProvisioningState = "Creating" + DeploymentProvisioningStateDeleting DeploymentProvisioningState = "Deleting" + DeploymentProvisioningStateFailed DeploymentProvisioningState = "Failed" + DeploymentProvisioningStateScaling DeploymentProvisioningState = "Scaling" + DeploymentProvisioningStateSucceeded DeploymentProvisioningState = "Succeeded" + DeploymentProvisioningStateUpdating DeploymentProvisioningState = "Updating" +) + +func PossibleValuesForDeploymentProvisioningState() []string { + return []string{ + string(DeploymentProvisioningStateCanceled), + string(DeploymentProvisioningStateCreating), + string(DeploymentProvisioningStateDeleting), + string(DeploymentProvisioningStateFailed), + string(DeploymentProvisioningStateScaling), + string(DeploymentProvisioningStateSucceeded), + string(DeploymentProvisioningStateUpdating), + } +} + +func (s *DeploymentProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDeploymentProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDeploymentProvisioningState(input string) (*DeploymentProvisioningState, error) { + vals := map[string]DeploymentProvisioningState{ + "canceled": DeploymentProvisioningStateCanceled, + "creating": DeploymentProvisioningStateCreating, + "deleting": DeploymentProvisioningStateDeleting, + "failed": DeploymentProvisioningStateFailed, + "scaling": DeploymentProvisioningStateScaling, + "succeeded": DeploymentProvisioningStateSucceeded, + "updating": DeploymentProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DeploymentProvisioningState(input) + return &out, nil +} + +type EgressPublicNetworkAccessType string + +const ( + EgressPublicNetworkAccessTypeDisabled EgressPublicNetworkAccessType = "Disabled" + EgressPublicNetworkAccessTypeEnabled EgressPublicNetworkAccessType = "Enabled" +) + +func PossibleValuesForEgressPublicNetworkAccessType() []string { + return []string{ + string(EgressPublicNetworkAccessTypeDisabled), + string(EgressPublicNetworkAccessTypeEnabled), + } +} + +func (s *EgressPublicNetworkAccessType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEgressPublicNetworkAccessType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEgressPublicNetworkAccessType(input string) (*EgressPublicNetworkAccessType, error) { + vals := map[string]EgressPublicNetworkAccessType{ + "disabled": EgressPublicNetworkAccessTypeDisabled, + "enabled": EgressPublicNetworkAccessTypeEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EgressPublicNetworkAccessType(input) + return &out, nil +} + +type EndpointComputeType string + +const ( + EndpointComputeTypeAzureMLCompute EndpointComputeType = "AzureMLCompute" + EndpointComputeTypeKubernetes EndpointComputeType = "Kubernetes" + EndpointComputeTypeManaged EndpointComputeType = "Managed" +) + +func PossibleValuesForEndpointComputeType() []string { + return []string{ + string(EndpointComputeTypeAzureMLCompute), + string(EndpointComputeTypeKubernetes), + string(EndpointComputeTypeManaged), + } +} + +func (s *EndpointComputeType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEndpointComputeType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEndpointComputeType(input string) (*EndpointComputeType, error) { + vals := map[string]EndpointComputeType{ + "azuremlcompute": EndpointComputeTypeAzureMLCompute, + "kubernetes": EndpointComputeTypeKubernetes, + "managed": EndpointComputeTypeManaged, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EndpointComputeType(input) + return &out, nil +} + +type RollingRateType string + +const ( + RollingRateTypeDay RollingRateType = "Day" + RollingRateTypeHour RollingRateType = "Hour" + RollingRateTypeMinute RollingRateType = "Minute" + RollingRateTypeMonth RollingRateType = "Month" + RollingRateTypeYear RollingRateType = "Year" +) + +func PossibleValuesForRollingRateType() []string { + return []string{ + string(RollingRateTypeDay), + string(RollingRateTypeHour), + string(RollingRateTypeMinute), + string(RollingRateTypeMonth), + string(RollingRateTypeYear), + } +} + +func (s *RollingRateType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRollingRateType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRollingRateType(input string) (*RollingRateType, error) { + vals := map[string]RollingRateType{ + "day": RollingRateTypeDay, + "hour": RollingRateTypeHour, + "minute": RollingRateTypeMinute, + "month": RollingRateTypeMonth, + "year": RollingRateTypeYear, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RollingRateType(input) + return &out, nil +} + +type ScaleType string + +const ( + ScaleTypeDefault ScaleType = "Default" + ScaleTypeTargetUtilization ScaleType = "TargetUtilization" +) + +func PossibleValuesForScaleType() []string { + return []string{ + string(ScaleTypeDefault), + string(ScaleTypeTargetUtilization), + } +} + +func (s *ScaleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScaleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScaleType(input string) (*ScaleType, error) { + vals := map[string]ScaleType{ + "default": ScaleTypeDefault, + "targetutilization": ScaleTypeTargetUtilization, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScaleType(input) + return &out, nil +} + +type SkuScaleType string + +const ( + SkuScaleTypeAutomatic SkuScaleType = "Automatic" + SkuScaleTypeManual SkuScaleType = "Manual" + SkuScaleTypeNone SkuScaleType = "None" +) + +func PossibleValuesForSkuScaleType() []string { + return []string{ + string(SkuScaleTypeAutomatic), + string(SkuScaleTypeManual), + string(SkuScaleTypeNone), + } +} + +func (s *SkuScaleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuScaleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuScaleType(input string) (*SkuScaleType, error) { + vals := map[string]SkuScaleType{ + "automatic": SkuScaleTypeAutomatic, + "manual": SkuScaleTypeManual, + "none": SkuScaleTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuScaleType(input) + return &out, nil +} + +type SkuTier string + +const ( + SkuTierBasic SkuTier = "Basic" + SkuTierFree SkuTier = "Free" + SkuTierPremium SkuTier = "Premium" + SkuTierStandard SkuTier = "Standard" +) + +func PossibleValuesForSkuTier() []string { + return []string{ + string(SkuTierBasic), + string(SkuTierFree), + string(SkuTierPremium), + string(SkuTierStandard), + } +} + +func (s *SkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuTier(input string) (*SkuTier, error) { + vals := map[string]SkuTier{ + "basic": SkuTierBasic, + "free": SkuTierFree, + "premium": SkuTierPremium, + "standard": SkuTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuTier(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/id_onlineendpoint.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/id_onlineendpoint.go new file mode 100644 index 00000000000..df56bd7d9ca --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/id_onlineendpoint.go @@ -0,0 +1,139 @@ +package onlinedeployment + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&OnlineEndpointId{}) +} + +var _ resourceids.ResourceId = &OnlineEndpointId{} + +// OnlineEndpointId is a struct representing the Resource ID for a Online Endpoint +type OnlineEndpointId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + OnlineEndpointName string +} + +// NewOnlineEndpointID returns a new OnlineEndpointId struct +func NewOnlineEndpointID(subscriptionId string, resourceGroupName string, workspaceName string, onlineEndpointName string) OnlineEndpointId { + return OnlineEndpointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + OnlineEndpointName: onlineEndpointName, + } +} + +// ParseOnlineEndpointID parses 'input' into a OnlineEndpointId +func ParseOnlineEndpointID(input string) (*OnlineEndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&OnlineEndpointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := OnlineEndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseOnlineEndpointIDInsensitively parses 'input' case-insensitively into a OnlineEndpointId +// note: this method should only be used for API response data and not user input +func ParseOnlineEndpointIDInsensitively(input string) (*OnlineEndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&OnlineEndpointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := OnlineEndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *OnlineEndpointId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.OnlineEndpointName, ok = input.Parsed["onlineEndpointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "onlineEndpointName", input) + } + + return nil +} + +// ValidateOnlineEndpointID checks that 'input' can be parsed as a Online Endpoint ID +func ValidateOnlineEndpointID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseOnlineEndpointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Online Endpoint ID +func (id OnlineEndpointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/onlineEndpoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.OnlineEndpointName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Online Endpoint ID +func (id OnlineEndpointId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticOnlineEndpoints", "onlineEndpoints", "onlineEndpoints"), + resourceids.UserSpecifiedSegment("onlineEndpointName", "onlineEndpointName"), + } +} + +// String returns a human-readable description of this Online Endpoint ID +func (id OnlineEndpointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Online Endpoint Name: %q", id.OnlineEndpointName), + } + return fmt.Sprintf("Online Endpoint (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/id_onlineendpoint_test.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/id_onlineendpoint_test.go new file mode 100644 index 00000000000..100042f00e0 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/id_onlineendpoint_test.go @@ -0,0 +1,327 @@ +package onlinedeployment + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &OnlineEndpointId{} + +func TestNewOnlineEndpointID(t *testing.T) { + id := NewOnlineEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "onlineEndpointName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.OnlineEndpointName != "onlineEndpointName" { + t.Fatalf("Expected %q but got %q for Segment 'OnlineEndpointName'", id.OnlineEndpointName, "onlineEndpointName") + } +} + +func TestFormatOnlineEndpointID(t *testing.T) { + actual := NewOnlineEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "onlineEndpointName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/onlineEndpoints/onlineEndpointName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseOnlineEndpointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *OnlineEndpointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/onlineEndpoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/onlineEndpoints/onlineEndpointName", + Expected: &OnlineEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + OnlineEndpointName: "onlineEndpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/onlineEndpoints/onlineEndpointName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseOnlineEndpointID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.OnlineEndpointName != v.Expected.OnlineEndpointName { + t.Fatalf("Expected %q but got %q for OnlineEndpointName", v.Expected.OnlineEndpointName, actual.OnlineEndpointName) + } + + } +} + +func TestParseOnlineEndpointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *OnlineEndpointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/onlineEndpoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/oNlInEeNdPoInTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/onlineEndpoints/onlineEndpointName", + Expected: &OnlineEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + OnlineEndpointName: "onlineEndpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/onlineEndpoints/onlineEndpointName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/oNlInEeNdPoInTs/oNlInEeNdPoInTnAmE", + Expected: &OnlineEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + OnlineEndpointName: "oNlInEeNdPoInTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/oNlInEeNdPoInTs/oNlInEeNdPoInTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseOnlineEndpointIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.OnlineEndpointName != v.Expected.OnlineEndpointName { + t.Fatalf("Expected %q but got %q for OnlineEndpointName", v.Expected.OnlineEndpointName, actual.OnlineEndpointName) + } + + } +} + +func TestSegmentsForOnlineEndpointId(t *testing.T) { + segments := OnlineEndpointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("OnlineEndpointId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/id_onlineendpointdeployment.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/id_onlineendpointdeployment.go new file mode 100644 index 00000000000..386acc10d5e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/id_onlineendpointdeployment.go @@ -0,0 +1,148 @@ +package onlinedeployment + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&OnlineEndpointDeploymentId{}) +} + +var _ resourceids.ResourceId = &OnlineEndpointDeploymentId{} + +// OnlineEndpointDeploymentId is a struct representing the Resource ID for a Online Endpoint Deployment +type OnlineEndpointDeploymentId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + OnlineEndpointName string + DeploymentName string +} + +// NewOnlineEndpointDeploymentID returns a new OnlineEndpointDeploymentId struct +func NewOnlineEndpointDeploymentID(subscriptionId string, resourceGroupName string, workspaceName string, onlineEndpointName string, deploymentName string) OnlineEndpointDeploymentId { + return OnlineEndpointDeploymentId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + OnlineEndpointName: onlineEndpointName, + DeploymentName: deploymentName, + } +} + +// ParseOnlineEndpointDeploymentID parses 'input' into a OnlineEndpointDeploymentId +func ParseOnlineEndpointDeploymentID(input string) (*OnlineEndpointDeploymentId, error) { + parser := resourceids.NewParserFromResourceIdType(&OnlineEndpointDeploymentId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := OnlineEndpointDeploymentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseOnlineEndpointDeploymentIDInsensitively parses 'input' case-insensitively into a OnlineEndpointDeploymentId +// note: this method should only be used for API response data and not user input +func ParseOnlineEndpointDeploymentIDInsensitively(input string) (*OnlineEndpointDeploymentId, error) { + parser := resourceids.NewParserFromResourceIdType(&OnlineEndpointDeploymentId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := OnlineEndpointDeploymentId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *OnlineEndpointDeploymentId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.OnlineEndpointName, ok = input.Parsed["onlineEndpointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "onlineEndpointName", input) + } + + if id.DeploymentName, ok = input.Parsed["deploymentName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "deploymentName", input) + } + + return nil +} + +// ValidateOnlineEndpointDeploymentID checks that 'input' can be parsed as a Online Endpoint Deployment ID +func ValidateOnlineEndpointDeploymentID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseOnlineEndpointDeploymentID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Online Endpoint Deployment ID +func (id OnlineEndpointDeploymentId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/onlineEndpoints/%s/deployments/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.OnlineEndpointName, id.DeploymentName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Online Endpoint Deployment ID +func (id OnlineEndpointDeploymentId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticOnlineEndpoints", "onlineEndpoints", "onlineEndpoints"), + resourceids.UserSpecifiedSegment("onlineEndpointName", "onlineEndpointName"), + resourceids.StaticSegment("staticDeployments", "deployments", "deployments"), + resourceids.UserSpecifiedSegment("deploymentName", "deploymentName"), + } +} + +// String returns a human-readable description of this Online Endpoint Deployment ID +func (id OnlineEndpointDeploymentId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Online Endpoint Name: %q", id.OnlineEndpointName), + fmt.Sprintf("Deployment Name: %q", id.DeploymentName), + } + return fmt.Sprintf("Online Endpoint Deployment (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/id_onlineendpointdeployment_test.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/id_onlineendpointdeployment_test.go new file mode 100644 index 00000000000..e856ed49885 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/id_onlineendpointdeployment_test.go @@ -0,0 +1,372 @@ +package onlinedeployment + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &OnlineEndpointDeploymentId{} + +func TestNewOnlineEndpointDeploymentID(t *testing.T) { + id := NewOnlineEndpointDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "onlineEndpointName", "deploymentName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.OnlineEndpointName != "onlineEndpointName" { + t.Fatalf("Expected %q but got %q for Segment 'OnlineEndpointName'", id.OnlineEndpointName, "onlineEndpointName") + } + + if id.DeploymentName != "deploymentName" { + t.Fatalf("Expected %q but got %q for Segment 'DeploymentName'", id.DeploymentName, "deploymentName") + } +} + +func TestFormatOnlineEndpointDeploymentID(t *testing.T) { + actual := NewOnlineEndpointDeploymentID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "onlineEndpointName", "deploymentName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/onlineEndpoints/onlineEndpointName/deployments/deploymentName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseOnlineEndpointDeploymentID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *OnlineEndpointDeploymentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/onlineEndpoints", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/onlineEndpoints/onlineEndpointName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/onlineEndpoints/onlineEndpointName/deployments", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/onlineEndpoints/onlineEndpointName/deployments/deploymentName", + Expected: &OnlineEndpointDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + OnlineEndpointName: "onlineEndpointName", + DeploymentName: "deploymentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/onlineEndpoints/onlineEndpointName/deployments/deploymentName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseOnlineEndpointDeploymentID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.OnlineEndpointName != v.Expected.OnlineEndpointName { + t.Fatalf("Expected %q but got %q for OnlineEndpointName", v.Expected.OnlineEndpointName, actual.OnlineEndpointName) + } + + if actual.DeploymentName != v.Expected.DeploymentName { + t.Fatalf("Expected %q but got %q for DeploymentName", v.Expected.DeploymentName, actual.DeploymentName) + } + + } +} + +func TestParseOnlineEndpointDeploymentIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *OnlineEndpointDeploymentId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/onlineEndpoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/oNlInEeNdPoInTs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/onlineEndpoints/onlineEndpointName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/oNlInEeNdPoInTs/oNlInEeNdPoInTnAmE", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/onlineEndpoints/onlineEndpointName/deployments", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/oNlInEeNdPoInTs/oNlInEeNdPoInTnAmE/dEpLoYmEnTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/onlineEndpoints/onlineEndpointName/deployments/deploymentName", + Expected: &OnlineEndpointDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + OnlineEndpointName: "onlineEndpointName", + DeploymentName: "deploymentName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/onlineEndpoints/onlineEndpointName/deployments/deploymentName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/oNlInEeNdPoInTs/oNlInEeNdPoInTnAmE/dEpLoYmEnTs/dEpLoYmEnTnAmE", + Expected: &OnlineEndpointDeploymentId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + OnlineEndpointName: "oNlInEeNdPoInTnAmE", + DeploymentName: "dEpLoYmEnTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/oNlInEeNdPoInTs/oNlInEeNdPoInTnAmE/dEpLoYmEnTs/dEpLoYmEnTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseOnlineEndpointDeploymentIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.OnlineEndpointName != v.Expected.OnlineEndpointName { + t.Fatalf("Expected %q but got %q for OnlineEndpointName", v.Expected.OnlineEndpointName, actual.OnlineEndpointName) + } + + if actual.DeploymentName != v.Expected.DeploymentName { + t.Fatalf("Expected %q but got %q for DeploymentName", v.Expected.DeploymentName, actual.DeploymentName) + } + + } +} + +func TestSegmentsForOnlineEndpointDeploymentId(t *testing.T) { + segments := OnlineEndpointDeploymentId{}.Segments() + if len(segments) == 0 { + t.Fatalf("OnlineEndpointDeploymentId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/method_createorupdate.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/method_createorupdate.go new file mode 100644 index 00000000000..eae03c182f6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/method_createorupdate.go @@ -0,0 +1,75 @@ +package onlinedeployment + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *OnlineDeploymentTrackedResource +} + +// CreateOrUpdate ... +func (c OnlineDeploymentClient) CreateOrUpdate(ctx context.Context, id OnlineEndpointDeploymentId, input OnlineDeploymentTrackedResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c OnlineDeploymentClient) CreateOrUpdateThenPoll(ctx context.Context, id OnlineEndpointDeploymentId, input OnlineDeploymentTrackedResource) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/method_delete.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/method_delete.go new file mode 100644 index 00000000000..89377e53136 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/method_delete.go @@ -0,0 +1,71 @@ +package onlinedeployment + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 OnlineDeploymentClient) Delete(ctx context.Context, id OnlineEndpointDeploymentId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c OnlineDeploymentClient) DeleteThenPoll(ctx context.Context, id OnlineEndpointDeploymentId) 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/machinelearningservices/2025-04-01/onlinedeployment/method_get.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/method_get.go new file mode 100644 index 00000000000..a10bc75e646 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/method_get.go @@ -0,0 +1,53 @@ +package onlinedeployment + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *OnlineDeploymentTrackedResource +} + +// Get ... +func (c OnlineDeploymentClient) Get(ctx context.Context, id OnlineEndpointDeploymentId) (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 OnlineDeploymentTrackedResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/method_getlogs.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/method_getlogs.go new file mode 100644 index 00000000000..7e9e4964bc6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/method_getlogs.go @@ -0,0 +1,58 @@ +package onlinedeployment + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetLogsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *DeploymentLogs +} + +// GetLogs ... +func (c OnlineDeploymentClient) GetLogs(ctx context.Context, id OnlineEndpointDeploymentId, input DeploymentLogsRequest) (result GetLogsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/getLogs", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model DeploymentLogs + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/method_list.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/method_list.go new file mode 100644 index 00000000000..3b219f5d0e6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/method_list.go @@ -0,0 +1,142 @@ +package onlinedeployment + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]OnlineDeploymentTrackedResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []OnlineDeploymentTrackedResource +} + +type ListOperationOptions struct { + OrderBy *string + Skip *string + Top *int64 +} + +func DefaultListOperationOptions() ListOperationOptions { + return ListOperationOptions{} +} + +func (o ListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.OrderBy != nil { + out.Append("$orderBy", fmt.Sprintf("%v", *o.OrderBy)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Top != nil { + out.Append("$top", fmt.Sprintf("%v", *o.Top)) + } + return &out +} + +type ListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// List ... +func (c OnlineDeploymentClient) List(ctx context.Context, id OnlineEndpointId, 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/deployments", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]OnlineDeploymentTrackedResource `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 OnlineDeploymentClient) ListComplete(ctx context.Context, id OnlineEndpointId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, OnlineDeploymentTrackedResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c OnlineDeploymentClient) ListCompleteMatchingPredicate(ctx context.Context, id OnlineEndpointId, options ListOperationOptions, predicate OnlineDeploymentTrackedResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]OnlineDeploymentTrackedResource, 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/machinelearningservices/2025-04-01/onlinedeployment/method_listskus.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/method_listskus.go new file mode 100644 index 00000000000..f2374db32ae --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/method_listskus.go @@ -0,0 +1,138 @@ +package onlinedeployment + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListSkusOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]SkuResource +} + +type ListSkusCompleteResult struct { + LatestHttpResponse *http.Response + Items []SkuResource +} + +type ListSkusOperationOptions struct { + Count *int64 + Skip *string +} + +func DefaultListSkusOperationOptions() ListSkusOperationOptions { + return ListSkusOperationOptions{} +} + +func (o ListSkusOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListSkusOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListSkusOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Count != nil { + out.Append("count", fmt.Sprintf("%v", *o.Count)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + return &out +} + +type ListSkusCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListSkusCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListSkus ... +func (c OnlineDeploymentClient) ListSkus(ctx context.Context, id OnlineEndpointDeploymentId, options ListSkusOperationOptions) (result ListSkusOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListSkusCustomPager{}, + Path: fmt.Sprintf("%s/skus", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]SkuResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListSkusComplete retrieves all the results into a single object +func (c OnlineDeploymentClient) ListSkusComplete(ctx context.Context, id OnlineEndpointDeploymentId, options ListSkusOperationOptions) (ListSkusCompleteResult, error) { + return c.ListSkusCompleteMatchingPredicate(ctx, id, options, SkuResourceOperationPredicate{}) +} + +// ListSkusCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c OnlineDeploymentClient) ListSkusCompleteMatchingPredicate(ctx context.Context, id OnlineEndpointDeploymentId, options ListSkusOperationOptions, predicate SkuResourceOperationPredicate) (result ListSkusCompleteResult, err error) { + items := make([]SkuResource, 0) + + resp, err := c.ListSkus(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 = ListSkusCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/method_update.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/method_update.go new file mode 100644 index 00000000000..0d681875c3e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/method_update.go @@ -0,0 +1,75 @@ +package onlinedeployment + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *OnlineDeploymentTrackedResource +} + +// Update ... +func (c OnlineDeploymentClient) Update(ctx context.Context, id OnlineEndpointDeploymentId, input PartialMinimalTrackedResourceWithSku) (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 OnlineDeploymentClient) UpdateThenPoll(ctx context.Context, id OnlineEndpointDeploymentId, input PartialMinimalTrackedResourceWithSku) 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/machinelearningservices/2025-04-01/onlinedeployment/model_codeconfiguration.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_codeconfiguration.go new file mode 100644 index 00000000000..a03efc99042 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_codeconfiguration.go @@ -0,0 +1,9 @@ +package onlinedeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CodeConfiguration struct { + CodeId *string `json:"codeId,omitempty"` + ScoringScript string `json:"scoringScript"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_collection.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_collection.go new file mode 100644 index 00000000000..f063f672493 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_collection.go @@ -0,0 +1,11 @@ +package onlinedeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Collection struct { + ClientId *string `json:"clientId,omitempty"` + DataCollectionMode *DataCollectionMode `json:"dataCollectionMode,omitempty"` + DataId *string `json:"dataId,omitempty"` + SamplingRate *float64 `json:"samplingRate,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_containerresourcerequirements.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_containerresourcerequirements.go new file mode 100644 index 00000000000..2707f1b39ea --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_containerresourcerequirements.go @@ -0,0 +1,9 @@ +package onlinedeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerResourceRequirements struct { + ContainerResourceLimits *ContainerResourceSettings `json:"containerResourceLimits,omitempty"` + ContainerResourceRequests *ContainerResourceSettings `json:"containerResourceRequests,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_containerresourcesettings.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_containerresourcesettings.go new file mode 100644 index 00000000000..a51d03d031e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_containerresourcesettings.go @@ -0,0 +1,10 @@ +package onlinedeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContainerResourceSettings struct { + Cpu *string `json:"cpu,omitempty"` + Gpu *string `json:"gpu,omitempty"` + Memory *string `json:"memory,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_datacollector.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_datacollector.go new file mode 100644 index 00000000000..d4095d97058 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_datacollector.go @@ -0,0 +1,10 @@ +package onlinedeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataCollector struct { + Collections map[string]Collection `json:"collections"` + RequestLogging *RequestLogging `json:"requestLogging,omitempty"` + RollingRate *RollingRateType `json:"rollingRate,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_defaultscalesettings.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_defaultscalesettings.go new file mode 100644 index 00000000000..6235621a9a2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_defaultscalesettings.go @@ -0,0 +1,49 @@ +package onlinedeployment + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ OnlineScaleSettings = DefaultScaleSettings{} + +type DefaultScaleSettings struct { + + // Fields inherited from OnlineScaleSettings + + ScaleType ScaleType `json:"scaleType"` +} + +func (s DefaultScaleSettings) OnlineScaleSettings() BaseOnlineScaleSettingsImpl { + return BaseOnlineScaleSettingsImpl{ + ScaleType: s.ScaleType, + } +} + +var _ json.Marshaler = DefaultScaleSettings{} + +func (s DefaultScaleSettings) MarshalJSON() ([]byte, error) { + type wrapper DefaultScaleSettings + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DefaultScaleSettings: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DefaultScaleSettings: %+v", err) + } + + decoded["scaleType"] = "Default" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DefaultScaleSettings: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_deploymentlogs.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_deploymentlogs.go new file mode 100644 index 00000000000..baf34632b30 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_deploymentlogs.go @@ -0,0 +1,8 @@ +package onlinedeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeploymentLogs struct { + Content *string `json:"content,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_deploymentlogsrequest.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_deploymentlogsrequest.go new file mode 100644 index 00000000000..9a90f4ba407 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_deploymentlogsrequest.go @@ -0,0 +1,9 @@ +package onlinedeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DeploymentLogsRequest struct { + ContainerType *ContainerType `json:"containerType,omitempty"` + Tail *int64 `json:"tail,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_kubernetesonlinedeployment.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_kubernetesonlinedeployment.go new file mode 100644 index 00000000000..7eea9a4f98c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_kubernetesonlinedeployment.go @@ -0,0 +1,146 @@ +package onlinedeployment + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ OnlineDeployment = KubernetesOnlineDeployment{} + +type KubernetesOnlineDeployment struct { + ContainerResourceRequirements *ContainerResourceRequirements `json:"containerResourceRequirements,omitempty"` + + // Fields inherited from OnlineDeployment + + AppInsightsEnabled *bool `json:"appInsightsEnabled,omitempty"` + CodeConfiguration *CodeConfiguration `json:"codeConfiguration,omitempty"` + DataCollector *DataCollector `json:"dataCollector,omitempty"` + Description *string `json:"description,omitempty"` + EgressPublicNetworkAccess *EgressPublicNetworkAccessType `json:"egressPublicNetworkAccess,omitempty"` + EndpointComputeType EndpointComputeType `json:"endpointComputeType"` + EnvironmentId *string `json:"environmentId,omitempty"` + EnvironmentVariables *map[string]string `json:"environmentVariables,omitempty"` + InstanceType *string `json:"instanceType,omitempty"` + LivenessProbe *ProbeSettings `json:"livenessProbe,omitempty"` + Model *string `json:"model,omitempty"` + ModelMountPath *string `json:"modelMountPath,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ProvisioningState *DeploymentProvisioningState `json:"provisioningState,omitempty"` + ReadinessProbe *ProbeSettings `json:"readinessProbe,omitempty"` + RequestSettings *OnlineRequestSettings `json:"requestSettings,omitempty"` + ScaleSettings OnlineScaleSettings `json:"scaleSettings"` + StartupProbe *ProbeSettings `json:"startupProbe,omitempty"` +} + +func (s KubernetesOnlineDeployment) OnlineDeployment() BaseOnlineDeploymentImpl { + return BaseOnlineDeploymentImpl{ + AppInsightsEnabled: s.AppInsightsEnabled, + CodeConfiguration: s.CodeConfiguration, + DataCollector: s.DataCollector, + Description: s.Description, + EgressPublicNetworkAccess: s.EgressPublicNetworkAccess, + EndpointComputeType: s.EndpointComputeType, + EnvironmentId: s.EnvironmentId, + EnvironmentVariables: s.EnvironmentVariables, + InstanceType: s.InstanceType, + LivenessProbe: s.LivenessProbe, + Model: s.Model, + ModelMountPath: s.ModelMountPath, + Properties: s.Properties, + ProvisioningState: s.ProvisioningState, + ReadinessProbe: s.ReadinessProbe, + RequestSettings: s.RequestSettings, + ScaleSettings: s.ScaleSettings, + StartupProbe: s.StartupProbe, + } +} + +var _ json.Marshaler = KubernetesOnlineDeployment{} + +func (s KubernetesOnlineDeployment) MarshalJSON() ([]byte, error) { + type wrapper KubernetesOnlineDeployment + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling KubernetesOnlineDeployment: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling KubernetesOnlineDeployment: %+v", err) + } + + decoded["endpointComputeType"] = "Kubernetes" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling KubernetesOnlineDeployment: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &KubernetesOnlineDeployment{} + +func (s *KubernetesOnlineDeployment) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ContainerResourceRequirements *ContainerResourceRequirements `json:"containerResourceRequirements,omitempty"` + AppInsightsEnabled *bool `json:"appInsightsEnabled,omitempty"` + CodeConfiguration *CodeConfiguration `json:"codeConfiguration,omitempty"` + DataCollector *DataCollector `json:"dataCollector,omitempty"` + Description *string `json:"description,omitempty"` + EgressPublicNetworkAccess *EgressPublicNetworkAccessType `json:"egressPublicNetworkAccess,omitempty"` + EndpointComputeType EndpointComputeType `json:"endpointComputeType"` + EnvironmentId *string `json:"environmentId,omitempty"` + EnvironmentVariables *map[string]string `json:"environmentVariables,omitempty"` + InstanceType *string `json:"instanceType,omitempty"` + LivenessProbe *ProbeSettings `json:"livenessProbe,omitempty"` + Model *string `json:"model,omitempty"` + ModelMountPath *string `json:"modelMountPath,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ProvisioningState *DeploymentProvisioningState `json:"provisioningState,omitempty"` + ReadinessProbe *ProbeSettings `json:"readinessProbe,omitempty"` + RequestSettings *OnlineRequestSettings `json:"requestSettings,omitempty"` + StartupProbe *ProbeSettings `json:"startupProbe,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ContainerResourceRequirements = decoded.ContainerResourceRequirements + s.AppInsightsEnabled = decoded.AppInsightsEnabled + s.CodeConfiguration = decoded.CodeConfiguration + s.DataCollector = decoded.DataCollector + s.Description = decoded.Description + s.EgressPublicNetworkAccess = decoded.EgressPublicNetworkAccess + s.EndpointComputeType = decoded.EndpointComputeType + s.EnvironmentId = decoded.EnvironmentId + s.EnvironmentVariables = decoded.EnvironmentVariables + s.InstanceType = decoded.InstanceType + s.LivenessProbe = decoded.LivenessProbe + s.Model = decoded.Model + s.ModelMountPath = decoded.ModelMountPath + s.Properties = decoded.Properties + s.ProvisioningState = decoded.ProvisioningState + s.ReadinessProbe = decoded.ReadinessProbe + s.RequestSettings = decoded.RequestSettings + s.StartupProbe = decoded.StartupProbe + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling KubernetesOnlineDeployment into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["scaleSettings"]; ok { + impl, err := UnmarshalOnlineScaleSettingsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ScaleSettings' for 'KubernetesOnlineDeployment': %+v", err) + } + s.ScaleSettings = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_managedonlinedeployment.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_managedonlinedeployment.go new file mode 100644 index 00000000000..d9c6b56fdf5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_managedonlinedeployment.go @@ -0,0 +1,143 @@ +package onlinedeployment + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ OnlineDeployment = ManagedOnlineDeployment{} + +type ManagedOnlineDeployment struct { + + // Fields inherited from OnlineDeployment + + AppInsightsEnabled *bool `json:"appInsightsEnabled,omitempty"` + CodeConfiguration *CodeConfiguration `json:"codeConfiguration,omitempty"` + DataCollector *DataCollector `json:"dataCollector,omitempty"` + Description *string `json:"description,omitempty"` + EgressPublicNetworkAccess *EgressPublicNetworkAccessType `json:"egressPublicNetworkAccess,omitempty"` + EndpointComputeType EndpointComputeType `json:"endpointComputeType"` + EnvironmentId *string `json:"environmentId,omitempty"` + EnvironmentVariables *map[string]string `json:"environmentVariables,omitempty"` + InstanceType *string `json:"instanceType,omitempty"` + LivenessProbe *ProbeSettings `json:"livenessProbe,omitempty"` + Model *string `json:"model,omitempty"` + ModelMountPath *string `json:"modelMountPath,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ProvisioningState *DeploymentProvisioningState `json:"provisioningState,omitempty"` + ReadinessProbe *ProbeSettings `json:"readinessProbe,omitempty"` + RequestSettings *OnlineRequestSettings `json:"requestSettings,omitempty"` + ScaleSettings OnlineScaleSettings `json:"scaleSettings"` + StartupProbe *ProbeSettings `json:"startupProbe,omitempty"` +} + +func (s ManagedOnlineDeployment) OnlineDeployment() BaseOnlineDeploymentImpl { + return BaseOnlineDeploymentImpl{ + AppInsightsEnabled: s.AppInsightsEnabled, + CodeConfiguration: s.CodeConfiguration, + DataCollector: s.DataCollector, + Description: s.Description, + EgressPublicNetworkAccess: s.EgressPublicNetworkAccess, + EndpointComputeType: s.EndpointComputeType, + EnvironmentId: s.EnvironmentId, + EnvironmentVariables: s.EnvironmentVariables, + InstanceType: s.InstanceType, + LivenessProbe: s.LivenessProbe, + Model: s.Model, + ModelMountPath: s.ModelMountPath, + Properties: s.Properties, + ProvisioningState: s.ProvisioningState, + ReadinessProbe: s.ReadinessProbe, + RequestSettings: s.RequestSettings, + ScaleSettings: s.ScaleSettings, + StartupProbe: s.StartupProbe, + } +} + +var _ json.Marshaler = ManagedOnlineDeployment{} + +func (s ManagedOnlineDeployment) MarshalJSON() ([]byte, error) { + type wrapper ManagedOnlineDeployment + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ManagedOnlineDeployment: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ManagedOnlineDeployment: %+v", err) + } + + decoded["endpointComputeType"] = "Managed" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ManagedOnlineDeployment: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &ManagedOnlineDeployment{} + +func (s *ManagedOnlineDeployment) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AppInsightsEnabled *bool `json:"appInsightsEnabled,omitempty"` + CodeConfiguration *CodeConfiguration `json:"codeConfiguration,omitempty"` + DataCollector *DataCollector `json:"dataCollector,omitempty"` + Description *string `json:"description,omitempty"` + EgressPublicNetworkAccess *EgressPublicNetworkAccessType `json:"egressPublicNetworkAccess,omitempty"` + EndpointComputeType EndpointComputeType `json:"endpointComputeType"` + EnvironmentId *string `json:"environmentId,omitempty"` + EnvironmentVariables *map[string]string `json:"environmentVariables,omitempty"` + InstanceType *string `json:"instanceType,omitempty"` + LivenessProbe *ProbeSettings `json:"livenessProbe,omitempty"` + Model *string `json:"model,omitempty"` + ModelMountPath *string `json:"modelMountPath,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ProvisioningState *DeploymentProvisioningState `json:"provisioningState,omitempty"` + ReadinessProbe *ProbeSettings `json:"readinessProbe,omitempty"` + RequestSettings *OnlineRequestSettings `json:"requestSettings,omitempty"` + StartupProbe *ProbeSettings `json:"startupProbe,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AppInsightsEnabled = decoded.AppInsightsEnabled + s.CodeConfiguration = decoded.CodeConfiguration + s.DataCollector = decoded.DataCollector + s.Description = decoded.Description + s.EgressPublicNetworkAccess = decoded.EgressPublicNetworkAccess + s.EndpointComputeType = decoded.EndpointComputeType + s.EnvironmentId = decoded.EnvironmentId + s.EnvironmentVariables = decoded.EnvironmentVariables + s.InstanceType = decoded.InstanceType + s.LivenessProbe = decoded.LivenessProbe + s.Model = decoded.Model + s.ModelMountPath = decoded.ModelMountPath + s.Properties = decoded.Properties + s.ProvisioningState = decoded.ProvisioningState + s.ReadinessProbe = decoded.ReadinessProbe + s.RequestSettings = decoded.RequestSettings + s.StartupProbe = decoded.StartupProbe + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ManagedOnlineDeployment into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["scaleSettings"]; ok { + impl, err := UnmarshalOnlineScaleSettingsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ScaleSettings' for 'ManagedOnlineDeployment': %+v", err) + } + s.ScaleSettings = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_onlinedeployment.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_onlinedeployment.go new file mode 100644 index 00000000000..8e9e2000a28 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_onlinedeployment.go @@ -0,0 +1,160 @@ +package onlinedeployment + +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 OnlineDeployment interface { + OnlineDeployment() BaseOnlineDeploymentImpl +} + +var _ OnlineDeployment = BaseOnlineDeploymentImpl{} + +type BaseOnlineDeploymentImpl struct { + AppInsightsEnabled *bool `json:"appInsightsEnabled,omitempty"` + CodeConfiguration *CodeConfiguration `json:"codeConfiguration,omitempty"` + DataCollector *DataCollector `json:"dataCollector,omitempty"` + Description *string `json:"description,omitempty"` + EgressPublicNetworkAccess *EgressPublicNetworkAccessType `json:"egressPublicNetworkAccess,omitempty"` + EndpointComputeType EndpointComputeType `json:"endpointComputeType"` + EnvironmentId *string `json:"environmentId,omitempty"` + EnvironmentVariables *map[string]string `json:"environmentVariables,omitempty"` + InstanceType *string `json:"instanceType,omitempty"` + LivenessProbe *ProbeSettings `json:"livenessProbe,omitempty"` + Model *string `json:"model,omitempty"` + ModelMountPath *string `json:"modelMountPath,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ProvisioningState *DeploymentProvisioningState `json:"provisioningState,omitempty"` + ReadinessProbe *ProbeSettings `json:"readinessProbe,omitempty"` + RequestSettings *OnlineRequestSettings `json:"requestSettings,omitempty"` + ScaleSettings OnlineScaleSettings `json:"scaleSettings"` + StartupProbe *ProbeSettings `json:"startupProbe,omitempty"` +} + +func (s BaseOnlineDeploymentImpl) OnlineDeployment() BaseOnlineDeploymentImpl { + return s +} + +var _ OnlineDeployment = RawOnlineDeploymentImpl{} + +// RawOnlineDeploymentImpl 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 RawOnlineDeploymentImpl struct { + onlineDeployment BaseOnlineDeploymentImpl + Type string + Values map[string]interface{} +} + +func (s RawOnlineDeploymentImpl) OnlineDeployment() BaseOnlineDeploymentImpl { + return s.onlineDeployment +} + +var _ json.Unmarshaler = &BaseOnlineDeploymentImpl{} + +func (s *BaseOnlineDeploymentImpl) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AppInsightsEnabled *bool `json:"appInsightsEnabled,omitempty"` + CodeConfiguration *CodeConfiguration `json:"codeConfiguration,omitempty"` + DataCollector *DataCollector `json:"dataCollector,omitempty"` + Description *string `json:"description,omitempty"` + EgressPublicNetworkAccess *EgressPublicNetworkAccessType `json:"egressPublicNetworkAccess,omitempty"` + EndpointComputeType EndpointComputeType `json:"endpointComputeType"` + EnvironmentId *string `json:"environmentId,omitempty"` + EnvironmentVariables *map[string]string `json:"environmentVariables,omitempty"` + InstanceType *string `json:"instanceType,omitempty"` + LivenessProbe *ProbeSettings `json:"livenessProbe,omitempty"` + Model *string `json:"model,omitempty"` + ModelMountPath *string `json:"modelMountPath,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ProvisioningState *DeploymentProvisioningState `json:"provisioningState,omitempty"` + ReadinessProbe *ProbeSettings `json:"readinessProbe,omitempty"` + RequestSettings *OnlineRequestSettings `json:"requestSettings,omitempty"` + StartupProbe *ProbeSettings `json:"startupProbe,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AppInsightsEnabled = decoded.AppInsightsEnabled + s.CodeConfiguration = decoded.CodeConfiguration + s.DataCollector = decoded.DataCollector + s.Description = decoded.Description + s.EgressPublicNetworkAccess = decoded.EgressPublicNetworkAccess + s.EndpointComputeType = decoded.EndpointComputeType + s.EnvironmentId = decoded.EnvironmentId + s.EnvironmentVariables = decoded.EnvironmentVariables + s.InstanceType = decoded.InstanceType + s.LivenessProbe = decoded.LivenessProbe + s.Model = decoded.Model + s.ModelMountPath = decoded.ModelMountPath + s.Properties = decoded.Properties + s.ProvisioningState = decoded.ProvisioningState + s.ReadinessProbe = decoded.ReadinessProbe + s.RequestSettings = decoded.RequestSettings + s.StartupProbe = decoded.StartupProbe + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling BaseOnlineDeploymentImpl into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["scaleSettings"]; ok { + impl, err := UnmarshalOnlineScaleSettingsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ScaleSettings' for 'BaseOnlineDeploymentImpl': %+v", err) + } + s.ScaleSettings = impl + } + + return nil +} + +func UnmarshalOnlineDeploymentImplementation(input []byte) (OnlineDeployment, 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 OnlineDeployment into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["endpointComputeType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Kubernetes") { + var out KubernetesOnlineDeployment + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into KubernetesOnlineDeployment: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Managed") { + var out ManagedOnlineDeployment + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ManagedOnlineDeployment: %+v", err) + } + return out, nil + } + + var parent BaseOnlineDeploymentImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseOnlineDeploymentImpl: %+v", err) + } + + return RawOnlineDeploymentImpl{ + onlineDeployment: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_onlinedeploymenttrackedresource.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_onlinedeploymenttrackedresource.go new file mode 100644 index 00000000000..98d30276daa --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_onlinedeploymenttrackedresource.go @@ -0,0 +1,69 @@ +package onlinedeployment + +import ( + "encoding/json" + "fmt" + + "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 OnlineDeploymentTrackedResource struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties OnlineDeployment `json:"properties"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &OnlineDeploymentTrackedResource{} + +func (s *OnlineDeploymentTrackedResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Id = decoded.Id + s.Identity = decoded.Identity + s.Kind = decoded.Kind + s.Location = decoded.Location + s.Name = decoded.Name + s.Sku = decoded.Sku + s.SystemData = decoded.SystemData + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling OnlineDeploymentTrackedResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalOnlineDeploymentImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'OnlineDeploymentTrackedResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_onlinerequestsettings.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_onlinerequestsettings.go new file mode 100644 index 00000000000..41e8975168d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_onlinerequestsettings.go @@ -0,0 +1,10 @@ +package onlinedeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OnlineRequestSettings struct { + MaxConcurrentRequestsPerInstance *int64 `json:"maxConcurrentRequestsPerInstance,omitempty"` + MaxQueueWait *string `json:"maxQueueWait,omitempty"` + RequestTimeout *string `json:"requestTimeout,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_onlinescalesettings.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_onlinescalesettings.go new file mode 100644 index 00000000000..7dd58378c2e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_onlinescalesettings.go @@ -0,0 +1,83 @@ +package onlinedeployment + +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 OnlineScaleSettings interface { + OnlineScaleSettings() BaseOnlineScaleSettingsImpl +} + +var _ OnlineScaleSettings = BaseOnlineScaleSettingsImpl{} + +type BaseOnlineScaleSettingsImpl struct { + ScaleType ScaleType `json:"scaleType"` +} + +func (s BaseOnlineScaleSettingsImpl) OnlineScaleSettings() BaseOnlineScaleSettingsImpl { + return s +} + +var _ OnlineScaleSettings = RawOnlineScaleSettingsImpl{} + +// RawOnlineScaleSettingsImpl 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 RawOnlineScaleSettingsImpl struct { + onlineScaleSettings BaseOnlineScaleSettingsImpl + Type string + Values map[string]interface{} +} + +func (s RawOnlineScaleSettingsImpl) OnlineScaleSettings() BaseOnlineScaleSettingsImpl { + return s.onlineScaleSettings +} + +func UnmarshalOnlineScaleSettingsImplementation(input []byte) (OnlineScaleSettings, 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 OnlineScaleSettings into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["scaleType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Default") { + var out DefaultScaleSettings + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DefaultScaleSettings: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "TargetUtilization") { + var out TargetUtilizationScaleSettings + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into TargetUtilizationScaleSettings: %+v", err) + } + return out, nil + } + + var parent BaseOnlineScaleSettingsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseOnlineScaleSettingsImpl: %+v", err) + } + + return RawOnlineScaleSettingsImpl{ + onlineScaleSettings: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_partialminimaltrackedresourcewithsku.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_partialminimaltrackedresourcewithsku.go new file mode 100644 index 00000000000..3f0d130bcf8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_partialminimaltrackedresourcewithsku.go @@ -0,0 +1,9 @@ +package onlinedeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PartialMinimalTrackedResourceWithSku struct { + Sku *PartialSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_partialsku.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_partialsku.go new file mode 100644 index 00000000000..18bdae0cdf7 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_partialsku.go @@ -0,0 +1,12 @@ +package onlinedeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PartialSku struct { + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Name *string `json:"name,omitempty"` + Size *string `json:"size,omitempty"` + Tier *SkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_probesettings.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_probesettings.go new file mode 100644 index 00000000000..41ddb90a1dc --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_probesettings.go @@ -0,0 +1,12 @@ +package onlinedeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ProbeSettings struct { + FailureThreshold *int64 `json:"failureThreshold,omitempty"` + InitialDelay *string `json:"initialDelay,omitempty"` + Period *string `json:"period,omitempty"` + SuccessThreshold *int64 `json:"successThreshold,omitempty"` + Timeout *string `json:"timeout,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_requestlogging.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_requestlogging.go new file mode 100644 index 00000000000..949ee85b750 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_requestlogging.go @@ -0,0 +1,8 @@ +package onlinedeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RequestLogging struct { + CaptureHeaders *[]string `json:"captureHeaders,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_sku.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_sku.go new file mode 100644 index 00000000000..3508e550806 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_sku.go @@ -0,0 +1,12 @@ +package onlinedeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Name string `json:"name"` + Size *string `json:"size,omitempty"` + Tier *SkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_skucapacity.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_skucapacity.go new file mode 100644 index 00000000000..2bd25fd9bd1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_skucapacity.go @@ -0,0 +1,11 @@ +package onlinedeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuCapacity struct { + Default *int64 `json:"default,omitempty"` + Maximum *int64 `json:"maximum,omitempty"` + Minimum *int64 `json:"minimum,omitempty"` + ScaleType *SkuScaleType `json:"scaleType,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_skuresource.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_skuresource.go new file mode 100644 index 00000000000..95c84631962 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_skuresource.go @@ -0,0 +1,10 @@ +package onlinedeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuResource struct { + Capacity *SkuCapacity `json:"capacity,omitempty"` + ResourceType *string `json:"resourceType,omitempty"` + Sku *SkuSetting `json:"sku,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_skusetting.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_skusetting.go new file mode 100644 index 00000000000..2107d1e3056 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_skusetting.go @@ -0,0 +1,9 @@ +package onlinedeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SkuSetting struct { + Name string `json:"name"` + Tier *SkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_targetutilizationscalesettings.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_targetutilizationscalesettings.go new file mode 100644 index 00000000000..0dce1012760 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/model_targetutilizationscalesettings.go @@ -0,0 +1,53 @@ +package onlinedeployment + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ OnlineScaleSettings = TargetUtilizationScaleSettings{} + +type TargetUtilizationScaleSettings struct { + MaxInstances *int64 `json:"maxInstances,omitempty"` + MinInstances *int64 `json:"minInstances,omitempty"` + PollingInterval *string `json:"pollingInterval,omitempty"` + TargetUtilizationPercentage *int64 `json:"targetUtilizationPercentage,omitempty"` + + // Fields inherited from OnlineScaleSettings + + ScaleType ScaleType `json:"scaleType"` +} + +func (s TargetUtilizationScaleSettings) OnlineScaleSettings() BaseOnlineScaleSettingsImpl { + return BaseOnlineScaleSettingsImpl{ + ScaleType: s.ScaleType, + } +} + +var _ json.Marshaler = TargetUtilizationScaleSettings{} + +func (s TargetUtilizationScaleSettings) MarshalJSON() ([]byte, error) { + type wrapper TargetUtilizationScaleSettings + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling TargetUtilizationScaleSettings: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling TargetUtilizationScaleSettings: %+v", err) + } + + decoded["scaleType"] = "TargetUtilization" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling TargetUtilizationScaleSettings: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/predicates.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/predicates.go new file mode 100644 index 00000000000..980224f2595 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/predicates.go @@ -0,0 +1,50 @@ +package onlinedeployment + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OnlineDeploymentTrackedResourceOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p OnlineDeploymentTrackedResourceOperationPredicate) Matches(input OnlineDeploymentTrackedResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type SkuResourceOperationPredicate struct { + ResourceType *string +} + +func (p SkuResourceOperationPredicate) Matches(input SkuResource) bool { + + if p.ResourceType != nil && (input.ResourceType == nil || *p.ResourceType != *input.ResourceType) { + return false + } + + return true +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/version.go b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/version.go new file mode 100644 index 00000000000..259d703b751 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlinedeployment/version.go @@ -0,0 +1,10 @@ +package onlinedeployment + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/onlinedeployment/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/README.md b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/README.md new file mode 100644 index 00000000000..8cf8b309af4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/README.md @@ -0,0 +1,148 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/onlineendpoint` Documentation + +The `onlineendpoint` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/onlineendpoint" +``` + + +### Client Initialization + +```go +client := onlineendpoint.NewOnlineEndpointClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `OnlineEndpointClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := onlineendpoint.NewOnlineEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "onlineEndpointName") + +payload := onlineendpoint.OnlineEndpointTrackedResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `OnlineEndpointClient.Delete` + +```go +ctx := context.TODO() +id := onlineendpoint.NewOnlineEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "onlineEndpointName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `OnlineEndpointClient.Get` + +```go +ctx := context.TODO() +id := onlineendpoint.NewOnlineEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "onlineEndpointName") + +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: `OnlineEndpointClient.GetToken` + +```go +ctx := context.TODO() +id := onlineendpoint.NewOnlineEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "onlineEndpointName") + +read, err := client.GetToken(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `OnlineEndpointClient.List` + +```go +ctx := context.TODO() +id := onlineendpoint.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +// alternatively `client.List(ctx, id, onlineendpoint.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, onlineendpoint.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `OnlineEndpointClient.ListKeys` + +```go +ctx := context.TODO() +id := onlineendpoint.NewOnlineEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "onlineEndpointName") + +read, err := client.ListKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `OnlineEndpointClient.RegenerateKeys` + +```go +ctx := context.TODO() +id := onlineendpoint.NewOnlineEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "onlineEndpointName") + +payload := onlineendpoint.RegenerateEndpointKeysRequest{ + // ... +} + + +if err := client.RegenerateKeysThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `OnlineEndpointClient.Update` + +```go +ctx := context.TODO() +id := onlineendpoint.NewOnlineEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "onlineEndpointName") + +payload := onlineendpoint.PartialMinimalTrackedResourceWithIdentity{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/client.go b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/client.go new file mode 100644 index 00000000000..9dfb0f561b5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/client.go @@ -0,0 +1,26 @@ +package onlineendpoint + +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 OnlineEndpointClient struct { + Client *resourcemanager.Client +} + +func NewOnlineEndpointClientWithBaseURI(sdkApi sdkEnv.Api) (*OnlineEndpointClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "onlineendpoint", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating OnlineEndpointClient: %+v", err) + } + + return &OnlineEndpointClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/constants.go b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/constants.go new file mode 100644 index 00000000000..30baaa100a3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/constants.go @@ -0,0 +1,374 @@ +package onlineendpoint + +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 EndpointAuthMode string + +const ( + EndpointAuthModeAADToken EndpointAuthMode = "AADToken" + EndpointAuthModeAMLToken EndpointAuthMode = "AMLToken" + EndpointAuthModeKey EndpointAuthMode = "Key" +) + +func PossibleValuesForEndpointAuthMode() []string { + return []string{ + string(EndpointAuthModeAADToken), + string(EndpointAuthModeAMLToken), + string(EndpointAuthModeKey), + } +} + +func (s *EndpointAuthMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEndpointAuthMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEndpointAuthMode(input string) (*EndpointAuthMode, error) { + vals := map[string]EndpointAuthMode{ + "aadtoken": EndpointAuthModeAADToken, + "amltoken": EndpointAuthModeAMLToken, + "key": EndpointAuthModeKey, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EndpointAuthMode(input) + return &out, nil +} + +type EndpointComputeType string + +const ( + EndpointComputeTypeAzureMLCompute EndpointComputeType = "AzureMLCompute" + EndpointComputeTypeKubernetes EndpointComputeType = "Kubernetes" + EndpointComputeTypeManaged EndpointComputeType = "Managed" +) + +func PossibleValuesForEndpointComputeType() []string { + return []string{ + string(EndpointComputeTypeAzureMLCompute), + string(EndpointComputeTypeKubernetes), + string(EndpointComputeTypeManaged), + } +} + +func (s *EndpointComputeType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEndpointComputeType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEndpointComputeType(input string) (*EndpointComputeType, error) { + vals := map[string]EndpointComputeType{ + "azuremlcompute": EndpointComputeTypeAzureMLCompute, + "kubernetes": EndpointComputeTypeKubernetes, + "managed": EndpointComputeTypeManaged, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EndpointComputeType(input) + return &out, nil +} + +type EndpointProvisioningState string + +const ( + EndpointProvisioningStateCanceled EndpointProvisioningState = "Canceled" + EndpointProvisioningStateCreating EndpointProvisioningState = "Creating" + EndpointProvisioningStateDeleting EndpointProvisioningState = "Deleting" + EndpointProvisioningStateFailed EndpointProvisioningState = "Failed" + EndpointProvisioningStateSucceeded EndpointProvisioningState = "Succeeded" + EndpointProvisioningStateUpdating EndpointProvisioningState = "Updating" +) + +func PossibleValuesForEndpointProvisioningState() []string { + return []string{ + string(EndpointProvisioningStateCanceled), + string(EndpointProvisioningStateCreating), + string(EndpointProvisioningStateDeleting), + string(EndpointProvisioningStateFailed), + string(EndpointProvisioningStateSucceeded), + string(EndpointProvisioningStateUpdating), + } +} + +func (s *EndpointProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEndpointProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEndpointProvisioningState(input string) (*EndpointProvisioningState, error) { + vals := map[string]EndpointProvisioningState{ + "canceled": EndpointProvisioningStateCanceled, + "creating": EndpointProvisioningStateCreating, + "deleting": EndpointProvisioningStateDeleting, + "failed": EndpointProvisioningStateFailed, + "succeeded": EndpointProvisioningStateSucceeded, + "updating": EndpointProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EndpointProvisioningState(input) + return &out, nil +} + +type KeyType string + +const ( + KeyTypePrimary KeyType = "Primary" + KeyTypeSecondary KeyType = "Secondary" +) + +func PossibleValuesForKeyType() []string { + return []string{ + string(KeyTypePrimary), + string(KeyTypeSecondary), + } +} + +func (s *KeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeyType(input string) (*KeyType, error) { + vals := map[string]KeyType{ + "primary": KeyTypePrimary, + "secondary": KeyTypeSecondary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyType(input) + return &out, nil +} + +type ManagedServiceIdentityType string + +const ( + ManagedServiceIdentityTypeNone ManagedServiceIdentityType = "None" + ManagedServiceIdentityTypeSystemAssigned ManagedServiceIdentityType = "SystemAssigned" + ManagedServiceIdentityTypeSystemAssignedUserAssigned ManagedServiceIdentityType = "SystemAssigned,UserAssigned" + ManagedServiceIdentityTypeUserAssigned ManagedServiceIdentityType = "UserAssigned" +) + +func PossibleValuesForManagedServiceIdentityType() []string { + return []string{ + string(ManagedServiceIdentityTypeNone), + string(ManagedServiceIdentityTypeSystemAssigned), + string(ManagedServiceIdentityTypeSystemAssignedUserAssigned), + string(ManagedServiceIdentityTypeUserAssigned), + } +} + +func (s *ManagedServiceIdentityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedServiceIdentityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedServiceIdentityType(input string) (*ManagedServiceIdentityType, error) { + vals := map[string]ManagedServiceIdentityType{ + "none": ManagedServiceIdentityTypeNone, + "systemassigned": ManagedServiceIdentityTypeSystemAssigned, + "systemassigned,userassigned": ManagedServiceIdentityTypeSystemAssignedUserAssigned, + "userassigned": ManagedServiceIdentityTypeUserAssigned, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedServiceIdentityType(input) + return &out, nil +} + +type OrderString string + +const ( + OrderStringCreatedAtAsc OrderString = "CreatedAtAsc" + OrderStringCreatedAtDesc OrderString = "CreatedAtDesc" + OrderStringUpdatedAtAsc OrderString = "UpdatedAtAsc" + OrderStringUpdatedAtDesc OrderString = "UpdatedAtDesc" +) + +func PossibleValuesForOrderString() []string { + return []string{ + string(OrderStringCreatedAtAsc), + string(OrderStringCreatedAtDesc), + string(OrderStringUpdatedAtAsc), + string(OrderStringUpdatedAtDesc), + } +} + +func (s *OrderString) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOrderString(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOrderString(input string) (*OrderString, error) { + vals := map[string]OrderString{ + "createdatasc": OrderStringCreatedAtAsc, + "createdatdesc": OrderStringCreatedAtDesc, + "updatedatasc": OrderStringUpdatedAtAsc, + "updatedatdesc": OrderStringUpdatedAtDesc, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OrderString(input) + return &out, nil +} + +type PublicNetworkAccessType string + +const ( + PublicNetworkAccessTypeDisabled PublicNetworkAccessType = "Disabled" + PublicNetworkAccessTypeEnabled PublicNetworkAccessType = "Enabled" +) + +func PossibleValuesForPublicNetworkAccessType() []string { + return []string{ + string(PublicNetworkAccessTypeDisabled), + string(PublicNetworkAccessTypeEnabled), + } +} + +func (s *PublicNetworkAccessType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePublicNetworkAccessType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePublicNetworkAccessType(input string) (*PublicNetworkAccessType, error) { + vals := map[string]PublicNetworkAccessType{ + "disabled": PublicNetworkAccessTypeDisabled, + "enabled": PublicNetworkAccessTypeEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PublicNetworkAccessType(input) + return &out, nil +} + +type SkuTier string + +const ( + SkuTierBasic SkuTier = "Basic" + SkuTierFree SkuTier = "Free" + SkuTierPremium SkuTier = "Premium" + SkuTierStandard SkuTier = "Standard" +) + +func PossibleValuesForSkuTier() []string { + return []string{ + string(SkuTierBasic), + string(SkuTierFree), + string(SkuTierPremium), + string(SkuTierStandard), + } +} + +func (s *SkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuTier(input string) (*SkuTier, error) { + vals := map[string]SkuTier{ + "basic": SkuTierBasic, + "free": SkuTierFree, + "premium": SkuTierPremium, + "standard": SkuTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuTier(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/id_onlineendpoint.go b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/id_onlineendpoint.go new file mode 100644 index 00000000000..d8ee2313500 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/id_onlineendpoint.go @@ -0,0 +1,139 @@ +package onlineendpoint + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&OnlineEndpointId{}) +} + +var _ resourceids.ResourceId = &OnlineEndpointId{} + +// OnlineEndpointId is a struct representing the Resource ID for a Online Endpoint +type OnlineEndpointId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + OnlineEndpointName string +} + +// NewOnlineEndpointID returns a new OnlineEndpointId struct +func NewOnlineEndpointID(subscriptionId string, resourceGroupName string, workspaceName string, onlineEndpointName string) OnlineEndpointId { + return OnlineEndpointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + OnlineEndpointName: onlineEndpointName, + } +} + +// ParseOnlineEndpointID parses 'input' into a OnlineEndpointId +func ParseOnlineEndpointID(input string) (*OnlineEndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&OnlineEndpointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := OnlineEndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseOnlineEndpointIDInsensitively parses 'input' case-insensitively into a OnlineEndpointId +// note: this method should only be used for API response data and not user input +func ParseOnlineEndpointIDInsensitively(input string) (*OnlineEndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&OnlineEndpointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := OnlineEndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *OnlineEndpointId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.OnlineEndpointName, ok = input.Parsed["onlineEndpointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "onlineEndpointName", input) + } + + return nil +} + +// ValidateOnlineEndpointID checks that 'input' can be parsed as a Online Endpoint ID +func ValidateOnlineEndpointID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseOnlineEndpointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Online Endpoint ID +func (id OnlineEndpointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/onlineEndpoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.OnlineEndpointName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Online Endpoint ID +func (id OnlineEndpointId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticOnlineEndpoints", "onlineEndpoints", "onlineEndpoints"), + resourceids.UserSpecifiedSegment("onlineEndpointName", "onlineEndpointName"), + } +} + +// String returns a human-readable description of this Online Endpoint ID +func (id OnlineEndpointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Online Endpoint Name: %q", id.OnlineEndpointName), + } + return fmt.Sprintf("Online Endpoint (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/id_onlineendpoint_test.go b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/id_onlineendpoint_test.go new file mode 100644 index 00000000000..54092b9e77d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/id_onlineendpoint_test.go @@ -0,0 +1,327 @@ +package onlineendpoint + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &OnlineEndpointId{} + +func TestNewOnlineEndpointID(t *testing.T) { + id := NewOnlineEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "onlineEndpointName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.OnlineEndpointName != "onlineEndpointName" { + t.Fatalf("Expected %q but got %q for Segment 'OnlineEndpointName'", id.OnlineEndpointName, "onlineEndpointName") + } +} + +func TestFormatOnlineEndpointID(t *testing.T) { + actual := NewOnlineEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "onlineEndpointName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/onlineEndpoints/onlineEndpointName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseOnlineEndpointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *OnlineEndpointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/onlineEndpoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/onlineEndpoints/onlineEndpointName", + Expected: &OnlineEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + OnlineEndpointName: "onlineEndpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/onlineEndpoints/onlineEndpointName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseOnlineEndpointID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.OnlineEndpointName != v.Expected.OnlineEndpointName { + t.Fatalf("Expected %q but got %q for OnlineEndpointName", v.Expected.OnlineEndpointName, actual.OnlineEndpointName) + } + + } +} + +func TestParseOnlineEndpointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *OnlineEndpointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/onlineEndpoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/oNlInEeNdPoInTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/onlineEndpoints/onlineEndpointName", + Expected: &OnlineEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + OnlineEndpointName: "onlineEndpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/onlineEndpoints/onlineEndpointName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/oNlInEeNdPoInTs/oNlInEeNdPoInTnAmE", + Expected: &OnlineEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + OnlineEndpointName: "oNlInEeNdPoInTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/oNlInEeNdPoInTs/oNlInEeNdPoInTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseOnlineEndpointIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.OnlineEndpointName != v.Expected.OnlineEndpointName { + t.Fatalf("Expected %q but got %q for OnlineEndpointName", v.Expected.OnlineEndpointName, actual.OnlineEndpointName) + } + + } +} + +func TestSegmentsForOnlineEndpointId(t *testing.T) { + segments := OnlineEndpointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("OnlineEndpointId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/id_workspace.go b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/id_workspace.go new file mode 100644 index 00000000000..68a9de5413c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/id_workspace.go @@ -0,0 +1,130 @@ +package onlineendpoint + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/id_workspace_test.go b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/id_workspace_test.go new file mode 100644 index 00000000000..f29ad942977 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/id_workspace_test.go @@ -0,0 +1,282 @@ +package onlineendpoint + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/method_createorupdate.go b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/method_createorupdate.go new file mode 100644 index 00000000000..95dbf2226d1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/method_createorupdate.go @@ -0,0 +1,75 @@ +package onlineendpoint + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *OnlineEndpointTrackedResource +} + +// CreateOrUpdate ... +func (c OnlineEndpointClient) CreateOrUpdate(ctx context.Context, id OnlineEndpointId, input OnlineEndpointTrackedResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c OnlineEndpointClient) CreateOrUpdateThenPoll(ctx context.Context, id OnlineEndpointId, input OnlineEndpointTrackedResource) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/method_delete.go b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/method_delete.go new file mode 100644 index 00000000000..d94502ef4e5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/method_delete.go @@ -0,0 +1,71 @@ +package onlineendpoint + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 OnlineEndpointClient) Delete(ctx context.Context, id OnlineEndpointId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c OnlineEndpointClient) DeleteThenPoll(ctx context.Context, id OnlineEndpointId) 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/machinelearningservices/2025-04-01/onlineendpoint/method_get.go b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/method_get.go new file mode 100644 index 00000000000..254cebaf565 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/method_get.go @@ -0,0 +1,53 @@ +package onlineendpoint + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *OnlineEndpointTrackedResource +} + +// Get ... +func (c OnlineEndpointClient) Get(ctx context.Context, id OnlineEndpointId) (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 OnlineEndpointTrackedResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/method_gettoken.go b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/method_gettoken.go new file mode 100644 index 00000000000..50eb0738bd0 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/method_gettoken.go @@ -0,0 +1,54 @@ +package onlineendpoint + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetTokenOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *EndpointAuthToken +} + +// GetToken ... +func (c OnlineEndpointClient) GetToken(ctx context.Context, id OnlineEndpointId) (result GetTokenOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/token", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model EndpointAuthToken + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/method_list.go b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/method_list.go new file mode 100644 index 00000000000..77f9a3cfe7a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/method_list.go @@ -0,0 +1,158 @@ +package onlineendpoint + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]OnlineEndpointTrackedResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []OnlineEndpointTrackedResource +} + +type ListOperationOptions struct { + ComputeType *EndpointComputeType + Count *int64 + Name *string + OrderBy *OrderString + Properties *string + Skip *string + Tags *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.ComputeType != nil { + out.Append("computeType", fmt.Sprintf("%v", *o.ComputeType)) + } + if o.Count != nil { + out.Append("count", fmt.Sprintf("%v", *o.Count)) + } + if o.Name != nil { + out.Append("name", fmt.Sprintf("%v", *o.Name)) + } + if o.OrderBy != nil { + out.Append("orderBy", fmt.Sprintf("%v", *o.OrderBy)) + } + if o.Properties != nil { + out.Append("properties", fmt.Sprintf("%v", *o.Properties)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + if o.Tags != nil { + out.Append("tags", fmt.Sprintf("%v", *o.Tags)) + } + 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 OnlineEndpointClient) List(ctx context.Context, id WorkspaceId, 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/onlineEndpoints", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]OnlineEndpointTrackedResource `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 OnlineEndpointClient) ListComplete(ctx context.Context, id WorkspaceId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, OnlineEndpointTrackedResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c OnlineEndpointClient) ListCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, options ListOperationOptions, predicate OnlineEndpointTrackedResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]OnlineEndpointTrackedResource, 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/machinelearningservices/2025-04-01/onlineendpoint/method_listkeys.go b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/method_listkeys.go new file mode 100644 index 00000000000..840db4430f9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/method_listkeys.go @@ -0,0 +1,54 @@ +package onlineendpoint + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *EndpointAuthKeys +} + +// ListKeys ... +func (c OnlineEndpointClient) ListKeys(ctx context.Context, id OnlineEndpointId) (result ListKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model EndpointAuthKeys + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/method_regeneratekeys.go b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/method_regeneratekeys.go new file mode 100644 index 00000000000..ae1d7782cfe --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/method_regeneratekeys.go @@ -0,0 +1,74 @@ +package onlineendpoint + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegenerateKeysOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RegenerateKeys ... +func (c OnlineEndpointClient) RegenerateKeys(ctx context.Context, id OnlineEndpointId, input RegenerateEndpointKeysRequest) (result RegenerateKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regenerateKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RegenerateKeysThenPoll performs RegenerateKeys then polls until it's completed +func (c OnlineEndpointClient) RegenerateKeysThenPoll(ctx context.Context, id OnlineEndpointId, input RegenerateEndpointKeysRequest) error { + result, err := c.RegenerateKeys(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RegenerateKeys: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegenerateKeys: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/method_update.go b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/method_update.go new file mode 100644 index 00000000000..db334aec30e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/method_update.go @@ -0,0 +1,75 @@ +package onlineendpoint + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *OnlineEndpointTrackedResource +} + +// Update ... +func (c OnlineEndpointClient) Update(ctx context.Context, id OnlineEndpointId, input PartialMinimalTrackedResourceWithIdentity) (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 OnlineEndpointClient) UpdateThenPoll(ctx context.Context, id OnlineEndpointId, input PartialMinimalTrackedResourceWithIdentity) 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/machinelearningservices/2025-04-01/onlineendpoint/model_endpointauthkeys.go b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/model_endpointauthkeys.go new file mode 100644 index 00000000000..13e320be88e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/model_endpointauthkeys.go @@ -0,0 +1,9 @@ +package onlineendpoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointAuthKeys struct { + PrimaryKey *string `json:"primaryKey,omitempty"` + SecondaryKey *string `json:"secondaryKey,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/model_endpointauthtoken.go b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/model_endpointauthtoken.go new file mode 100644 index 00000000000..f10853df88f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/model_endpointauthtoken.go @@ -0,0 +1,11 @@ +package onlineendpoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointAuthToken struct { + AccessToken *string `json:"accessToken,omitempty"` + ExpiryTimeUtc *int64 `json:"expiryTimeUtc,omitempty"` + RefreshAfterTimeUtc *int64 `json:"refreshAfterTimeUtc,omitempty"` + TokenType *string `json:"tokenType,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/model_onlineendpoint.go b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/model_onlineendpoint.go new file mode 100644 index 00000000000..f63b37ecf2a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/model_onlineendpoint.go @@ -0,0 +1,18 @@ +package onlineendpoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OnlineEndpoint struct { + AuthMode EndpointAuthMode `json:"authMode"` + Compute *string `json:"compute,omitempty"` + Description *string `json:"description,omitempty"` + Keys *EndpointAuthKeys `json:"keys,omitempty"` + MirrorTraffic *map[string]int64 `json:"mirrorTraffic,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ProvisioningState *EndpointProvisioningState `json:"provisioningState,omitempty"` + PublicNetworkAccess *PublicNetworkAccessType `json:"publicNetworkAccess,omitempty"` + ScoringUri *string `json:"scoringUri,omitempty"` + SwaggerUri *string `json:"swaggerUri,omitempty"` + Traffic *map[string]int64 `json:"traffic,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/model_onlineendpointtrackedresource.go b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/model_onlineendpointtrackedresource.go new file mode 100644 index 00000000000..ca5c4d86125 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/model_onlineendpointtrackedresource.go @@ -0,0 +1,22 @@ +package onlineendpoint + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OnlineEndpointTrackedResource struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties OnlineEndpoint `json:"properties"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/model_partialmanagedserviceidentity.go b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/model_partialmanagedserviceidentity.go new file mode 100644 index 00000000000..8035402ca8c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/model_partialmanagedserviceidentity.go @@ -0,0 +1,9 @@ +package onlineendpoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PartialManagedServiceIdentity struct { + Type *ManagedServiceIdentityType `json:"type,omitempty"` + UserAssignedIdentities *map[string]interface{} `json:"userAssignedIdentities,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/model_partialminimaltrackedresourcewithidentity.go b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/model_partialminimaltrackedresourcewithidentity.go new file mode 100644 index 00000000000..472b9997eaa --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/model_partialminimaltrackedresourcewithidentity.go @@ -0,0 +1,9 @@ +package onlineendpoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PartialMinimalTrackedResourceWithIdentity struct { + Identity *PartialManagedServiceIdentity `json:"identity,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/model_regenerateendpointkeysrequest.go b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/model_regenerateendpointkeysrequest.go new file mode 100644 index 00000000000..d2eadfc607c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/model_regenerateendpointkeysrequest.go @@ -0,0 +1,9 @@ +package onlineendpoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegenerateEndpointKeysRequest struct { + KeyType KeyType `json:"keyType"` + KeyValue *string `json:"keyValue,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/model_sku.go b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/model_sku.go new file mode 100644 index 00000000000..5e240dba29b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/model_sku.go @@ -0,0 +1,12 @@ +package onlineendpoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Name string `json:"name"` + Size *string `json:"size,omitempty"` + Tier *SkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/predicates.go b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/predicates.go new file mode 100644 index 00000000000..bb63f9f9e89 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/predicates.go @@ -0,0 +1,37 @@ +package onlineendpoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type OnlineEndpointTrackedResourceOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p OnlineEndpointTrackedResourceOperationPredicate) Matches(input OnlineEndpointTrackedResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/version.go b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/version.go new file mode 100644 index 00000000000..3e2244e101c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/onlineendpoint/version.go @@ -0,0 +1,10 @@ +package onlineendpoint + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/onlineendpoint/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/README.md b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/README.md new file mode 100644 index 00000000000..867ad522d4a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/README.md @@ -0,0 +1,151 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters` Documentation + +The `operationalizationclusters` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters" +``` + + +### Client Initialization + +```go +client := operationalizationclusters.NewOperationalizationClustersClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `OperationalizationClustersClient.ComputeCreateOrUpdate` + +```go +ctx := context.TODO() +id := operationalizationclusters.NewComputeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "computeName") + +payload := operationalizationclusters.ComputeResource{ + // ... +} + + +if err := client.ComputeCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `OperationalizationClustersClient.ComputeDelete` + +```go +ctx := context.TODO() +id := operationalizationclusters.NewComputeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "computeName") + +if err := client.ComputeDeleteThenPoll(ctx, id, operationalizationclusters.DefaultComputeDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `OperationalizationClustersClient.ComputeGet` + +```go +ctx := context.TODO() +id := operationalizationclusters.NewComputeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "computeName") + +read, err := client.ComputeGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `OperationalizationClustersClient.ComputeList` + +```go +ctx := context.TODO() +id := operationalizationclusters.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +// alternatively `client.ComputeList(ctx, id, operationalizationclusters.DefaultComputeListOperationOptions())` can be used to do batched pagination +items, err := client.ComputeListComplete(ctx, id, operationalizationclusters.DefaultComputeListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `OperationalizationClustersClient.ComputeListKeys` + +```go +ctx := context.TODO() +id := operationalizationclusters.NewComputeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "computeName") + +read, err := client.ComputeListKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `OperationalizationClustersClient.ComputeRestart` + +```go +ctx := context.TODO() +id := operationalizationclusters.NewComputeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "computeName") + +if err := client.ComputeRestartThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `OperationalizationClustersClient.ComputeStart` + +```go +ctx := context.TODO() +id := operationalizationclusters.NewComputeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "computeName") + +if err := client.ComputeStartThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `OperationalizationClustersClient.ComputeStop` + +```go +ctx := context.TODO() +id := operationalizationclusters.NewComputeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "computeName") + +if err := client.ComputeStopThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `OperationalizationClustersClient.ComputeUpdate` + +```go +ctx := context.TODO() +id := operationalizationclusters.NewComputeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "computeName") + +payload := operationalizationclusters.ClusterUpdateParameters{ + // ... +} + + +if err := client.ComputeUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/client.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/client.go new file mode 100644 index 00000000000..e140b29868a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/client.go @@ -0,0 +1,26 @@ +package operationalizationclusters + +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 OperationalizationClustersClient struct { + Client *resourcemanager.Client +} + +func NewOperationalizationClustersClientWithBaseURI(sdkApi sdkEnv.Api) (*OperationalizationClustersClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "operationalizationclusters", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating OperationalizationClustersClient: %+v", err) + } + + return &OperationalizationClustersClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/constants.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/constants.go new file mode 100644 index 00000000000..227af0c34fe --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/constants.go @@ -0,0 +1,1666 @@ +package operationalizationclusters + +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 AllocationState string + +const ( + AllocationStateResizing AllocationState = "Resizing" + AllocationStateSteady AllocationState = "Steady" +) + +func PossibleValuesForAllocationState() []string { + return []string{ + string(AllocationStateResizing), + string(AllocationStateSteady), + } +} + +func (s *AllocationState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAllocationState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAllocationState(input string) (*AllocationState, error) { + vals := map[string]AllocationState{ + "resizing": AllocationStateResizing, + "steady": AllocationStateSteady, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := AllocationState(input) + return &out, nil +} + +type ApplicationSharingPolicy string + +const ( + ApplicationSharingPolicyPersonal ApplicationSharingPolicy = "Personal" + ApplicationSharingPolicyShared ApplicationSharingPolicy = "Shared" +) + +func PossibleValuesForApplicationSharingPolicy() []string { + return []string{ + string(ApplicationSharingPolicyPersonal), + string(ApplicationSharingPolicyShared), + } +} + +func (s *ApplicationSharingPolicy) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseApplicationSharingPolicy(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseApplicationSharingPolicy(input string) (*ApplicationSharingPolicy, error) { + vals := map[string]ApplicationSharingPolicy{ + "personal": ApplicationSharingPolicyPersonal, + "shared": ApplicationSharingPolicyShared, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ApplicationSharingPolicy(input) + return &out, nil +} + +type Autosave string + +const ( + AutosaveLocal Autosave = "Local" + AutosaveNone Autosave = "None" + AutosaveRemote Autosave = "Remote" +) + +func PossibleValuesForAutosave() []string { + return []string{ + string(AutosaveLocal), + string(AutosaveNone), + string(AutosaveRemote), + } +} + +func (s *Autosave) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseAutosave(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseAutosave(input string) (*Autosave, error) { + vals := map[string]Autosave{ + "local": AutosaveLocal, + "none": AutosaveNone, + "remote": AutosaveRemote, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Autosave(input) + return &out, nil +} + +type Caching string + +const ( + CachingNone Caching = "None" + CachingReadOnly Caching = "ReadOnly" + CachingReadWrite Caching = "ReadWrite" +) + +func PossibleValuesForCaching() []string { + return []string{ + string(CachingNone), + string(CachingReadOnly), + string(CachingReadWrite), + } +} + +func (s *Caching) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCaching(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCaching(input string) (*Caching, error) { + vals := map[string]Caching{ + "none": CachingNone, + "readonly": CachingReadOnly, + "readwrite": CachingReadWrite, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Caching(input) + return &out, nil +} + +type ClusterPurpose string + +const ( + ClusterPurposeDenseProd ClusterPurpose = "DenseProd" + ClusterPurposeDevTest ClusterPurpose = "DevTest" + ClusterPurposeFastProd ClusterPurpose = "FastProd" +) + +func PossibleValuesForClusterPurpose() []string { + return []string{ + string(ClusterPurposeDenseProd), + string(ClusterPurposeDevTest), + string(ClusterPurposeFastProd), + } +} + +func (s *ClusterPurpose) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClusterPurpose(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClusterPurpose(input string) (*ClusterPurpose, error) { + vals := map[string]ClusterPurpose{ + "denseprod": ClusterPurposeDenseProd, + "devtest": ClusterPurposeDevTest, + "fastprod": ClusterPurposeFastProd, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClusterPurpose(input) + return &out, nil +} + +type ComputeInstanceAuthorizationType string + +const ( + ComputeInstanceAuthorizationTypePersonal ComputeInstanceAuthorizationType = "personal" +) + +func PossibleValuesForComputeInstanceAuthorizationType() []string { + return []string{ + string(ComputeInstanceAuthorizationTypePersonal), + } +} + +func (s *ComputeInstanceAuthorizationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseComputeInstanceAuthorizationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseComputeInstanceAuthorizationType(input string) (*ComputeInstanceAuthorizationType, error) { + vals := map[string]ComputeInstanceAuthorizationType{ + "personal": ComputeInstanceAuthorizationTypePersonal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ComputeInstanceAuthorizationType(input) + return &out, nil +} + +type ComputeInstanceState string + +const ( + ComputeInstanceStateCreateFailed ComputeInstanceState = "CreateFailed" + ComputeInstanceStateCreating ComputeInstanceState = "Creating" + ComputeInstanceStateDeleting ComputeInstanceState = "Deleting" + ComputeInstanceStateJobRunning ComputeInstanceState = "JobRunning" + ComputeInstanceStateRestarting ComputeInstanceState = "Restarting" + ComputeInstanceStateRunning ComputeInstanceState = "Running" + ComputeInstanceStateSettingUp ComputeInstanceState = "SettingUp" + ComputeInstanceStateSetupFailed ComputeInstanceState = "SetupFailed" + ComputeInstanceStateStarting ComputeInstanceState = "Starting" + ComputeInstanceStateStopped ComputeInstanceState = "Stopped" + ComputeInstanceStateStopping ComputeInstanceState = "Stopping" + ComputeInstanceStateUnknown ComputeInstanceState = "Unknown" + ComputeInstanceStateUnusable ComputeInstanceState = "Unusable" + ComputeInstanceStateUserSettingUp ComputeInstanceState = "UserSettingUp" + ComputeInstanceStateUserSetupFailed ComputeInstanceState = "UserSetupFailed" +) + +func PossibleValuesForComputeInstanceState() []string { + return []string{ + string(ComputeInstanceStateCreateFailed), + string(ComputeInstanceStateCreating), + string(ComputeInstanceStateDeleting), + string(ComputeInstanceStateJobRunning), + string(ComputeInstanceStateRestarting), + string(ComputeInstanceStateRunning), + string(ComputeInstanceStateSettingUp), + string(ComputeInstanceStateSetupFailed), + string(ComputeInstanceStateStarting), + string(ComputeInstanceStateStopped), + string(ComputeInstanceStateStopping), + string(ComputeInstanceStateUnknown), + string(ComputeInstanceStateUnusable), + string(ComputeInstanceStateUserSettingUp), + string(ComputeInstanceStateUserSetupFailed), + } +} + +func (s *ComputeInstanceState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseComputeInstanceState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseComputeInstanceState(input string) (*ComputeInstanceState, error) { + vals := map[string]ComputeInstanceState{ + "createfailed": ComputeInstanceStateCreateFailed, + "creating": ComputeInstanceStateCreating, + "deleting": ComputeInstanceStateDeleting, + "jobrunning": ComputeInstanceStateJobRunning, + "restarting": ComputeInstanceStateRestarting, + "running": ComputeInstanceStateRunning, + "settingup": ComputeInstanceStateSettingUp, + "setupfailed": ComputeInstanceStateSetupFailed, + "starting": ComputeInstanceStateStarting, + "stopped": ComputeInstanceStateStopped, + "stopping": ComputeInstanceStateStopping, + "unknown": ComputeInstanceStateUnknown, + "unusable": ComputeInstanceStateUnusable, + "usersettingup": ComputeInstanceStateUserSettingUp, + "usersetupfailed": ComputeInstanceStateUserSetupFailed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ComputeInstanceState(input) + return &out, nil +} + +type ComputePowerAction string + +const ( + ComputePowerActionStart ComputePowerAction = "Start" + ComputePowerActionStop ComputePowerAction = "Stop" +) + +func PossibleValuesForComputePowerAction() []string { + return []string{ + string(ComputePowerActionStart), + string(ComputePowerActionStop), + } +} + +func (s *ComputePowerAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseComputePowerAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseComputePowerAction(input string) (*ComputePowerAction, error) { + vals := map[string]ComputePowerAction{ + "start": ComputePowerActionStart, + "stop": ComputePowerActionStop, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ComputePowerAction(input) + return &out, nil +} + +type ComputeRecurrenceFrequency string + +const ( + ComputeRecurrenceFrequencyDay ComputeRecurrenceFrequency = "Day" + ComputeRecurrenceFrequencyHour ComputeRecurrenceFrequency = "Hour" + ComputeRecurrenceFrequencyMinute ComputeRecurrenceFrequency = "Minute" + ComputeRecurrenceFrequencyMonth ComputeRecurrenceFrequency = "Month" + ComputeRecurrenceFrequencyWeek ComputeRecurrenceFrequency = "Week" +) + +func PossibleValuesForComputeRecurrenceFrequency() []string { + return []string{ + string(ComputeRecurrenceFrequencyDay), + string(ComputeRecurrenceFrequencyHour), + string(ComputeRecurrenceFrequencyMinute), + string(ComputeRecurrenceFrequencyMonth), + string(ComputeRecurrenceFrequencyWeek), + } +} + +func (s *ComputeRecurrenceFrequency) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseComputeRecurrenceFrequency(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseComputeRecurrenceFrequency(input string) (*ComputeRecurrenceFrequency, error) { + vals := map[string]ComputeRecurrenceFrequency{ + "day": ComputeRecurrenceFrequencyDay, + "hour": ComputeRecurrenceFrequencyHour, + "minute": ComputeRecurrenceFrequencyMinute, + "month": ComputeRecurrenceFrequencyMonth, + "week": ComputeRecurrenceFrequencyWeek, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ComputeRecurrenceFrequency(input) + return &out, nil +} + +type ComputeTriggerType string + +const ( + ComputeTriggerTypeCron ComputeTriggerType = "Cron" + ComputeTriggerTypeRecurrence ComputeTriggerType = "Recurrence" +) + +func PossibleValuesForComputeTriggerType() []string { + return []string{ + string(ComputeTriggerTypeCron), + string(ComputeTriggerTypeRecurrence), + } +} + +func (s *ComputeTriggerType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseComputeTriggerType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseComputeTriggerType(input string) (*ComputeTriggerType, error) { + vals := map[string]ComputeTriggerType{ + "cron": ComputeTriggerTypeCron, + "recurrence": ComputeTriggerTypeRecurrence, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ComputeTriggerType(input) + return &out, nil +} + +type ComputeType string + +const ( + ComputeTypeAKS ComputeType = "AKS" + ComputeTypeAmlCompute ComputeType = "AmlCompute" + ComputeTypeComputeInstance ComputeType = "ComputeInstance" + ComputeTypeDataFactory ComputeType = "DataFactory" + ComputeTypeDataLakeAnalytics ComputeType = "DataLakeAnalytics" + ComputeTypeDatabricks ComputeType = "Databricks" + ComputeTypeHDInsight ComputeType = "HDInsight" + ComputeTypeKubernetes ComputeType = "Kubernetes" + ComputeTypeSynapseSpark ComputeType = "SynapseSpark" + ComputeTypeVirtualMachine ComputeType = "VirtualMachine" +) + +func PossibleValuesForComputeType() []string { + return []string{ + string(ComputeTypeAKS), + string(ComputeTypeAmlCompute), + string(ComputeTypeComputeInstance), + string(ComputeTypeDataFactory), + string(ComputeTypeDataLakeAnalytics), + string(ComputeTypeDatabricks), + string(ComputeTypeHDInsight), + string(ComputeTypeKubernetes), + string(ComputeTypeSynapseSpark), + string(ComputeTypeVirtualMachine), + } +} + +func (s *ComputeType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseComputeType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseComputeType(input string) (*ComputeType, error) { + vals := map[string]ComputeType{ + "aks": ComputeTypeAKS, + "amlcompute": ComputeTypeAmlCompute, + "computeinstance": ComputeTypeComputeInstance, + "datafactory": ComputeTypeDataFactory, + "datalakeanalytics": ComputeTypeDataLakeAnalytics, + "databricks": ComputeTypeDatabricks, + "hdinsight": ComputeTypeHDInsight, + "kubernetes": ComputeTypeKubernetes, + "synapsespark": ComputeTypeSynapseSpark, + "virtualmachine": ComputeTypeVirtualMachine, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ComputeType(input) + return &out, nil +} + +type ComputeWeekDay string + +const ( + ComputeWeekDayFriday ComputeWeekDay = "Friday" + ComputeWeekDayMonday ComputeWeekDay = "Monday" + ComputeWeekDaySaturday ComputeWeekDay = "Saturday" + ComputeWeekDaySunday ComputeWeekDay = "Sunday" + ComputeWeekDayThursday ComputeWeekDay = "Thursday" + ComputeWeekDayTuesday ComputeWeekDay = "Tuesday" + ComputeWeekDayWednesday ComputeWeekDay = "Wednesday" +) + +func PossibleValuesForComputeWeekDay() []string { + return []string{ + string(ComputeWeekDayFriday), + string(ComputeWeekDayMonday), + string(ComputeWeekDaySaturday), + string(ComputeWeekDaySunday), + string(ComputeWeekDayThursday), + string(ComputeWeekDayTuesday), + string(ComputeWeekDayWednesday), + } +} + +func (s *ComputeWeekDay) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseComputeWeekDay(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseComputeWeekDay(input string) (*ComputeWeekDay, error) { + vals := map[string]ComputeWeekDay{ + "friday": ComputeWeekDayFriday, + "monday": ComputeWeekDayMonday, + "saturday": ComputeWeekDaySaturday, + "sunday": ComputeWeekDaySunday, + "thursday": ComputeWeekDayThursday, + "tuesday": ComputeWeekDayTuesday, + "wednesday": ComputeWeekDayWednesday, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ComputeWeekDay(input) + return &out, nil +} + +type EnvironmentVariableType string + +const ( + EnvironmentVariableTypeLocal EnvironmentVariableType = "local" +) + +func PossibleValuesForEnvironmentVariableType() []string { + return []string{ + string(EnvironmentVariableTypeLocal), + } +} + +func (s *EnvironmentVariableType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEnvironmentVariableType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEnvironmentVariableType(input string) (*EnvironmentVariableType, error) { + vals := map[string]EnvironmentVariableType{ + "local": EnvironmentVariableTypeLocal, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EnvironmentVariableType(input) + return &out, nil +} + +type ImageType string + +const ( + ImageTypeAzureml ImageType = "azureml" + ImageTypeDocker ImageType = "docker" +) + +func PossibleValuesForImageType() []string { + return []string{ + string(ImageTypeAzureml), + string(ImageTypeDocker), + } +} + +func (s *ImageType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseImageType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseImageType(input string) (*ImageType, error) { + vals := map[string]ImageType{ + "azureml": ImageTypeAzureml, + "docker": ImageTypeDocker, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ImageType(input) + return &out, nil +} + +type LoadBalancerType string + +const ( + LoadBalancerTypeInternalLoadBalancer LoadBalancerType = "InternalLoadBalancer" + LoadBalancerTypePublicIP LoadBalancerType = "PublicIp" +) + +func PossibleValuesForLoadBalancerType() []string { + return []string{ + string(LoadBalancerTypeInternalLoadBalancer), + string(LoadBalancerTypePublicIP), + } +} + +func (s *LoadBalancerType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLoadBalancerType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLoadBalancerType(input string) (*LoadBalancerType, error) { + vals := map[string]LoadBalancerType{ + "internalloadbalancer": LoadBalancerTypeInternalLoadBalancer, + "publicip": LoadBalancerTypePublicIP, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LoadBalancerType(input) + return &out, nil +} + +type MountAction string + +const ( + MountActionMount MountAction = "Mount" + MountActionUnmount MountAction = "Unmount" +) + +func PossibleValuesForMountAction() []string { + return []string{ + string(MountActionMount), + string(MountActionUnmount), + } +} + +func (s *MountAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMountAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMountAction(input string) (*MountAction, error) { + vals := map[string]MountAction{ + "mount": MountActionMount, + "unmount": MountActionUnmount, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MountAction(input) + return &out, nil +} + +type MountState string + +const ( + MountStateMountFailed MountState = "MountFailed" + MountStateMountRequested MountState = "MountRequested" + MountStateMounted MountState = "Mounted" + MountStateUnmountFailed MountState = "UnmountFailed" + MountStateUnmountRequested MountState = "UnmountRequested" + MountStateUnmounted MountState = "Unmounted" +) + +func PossibleValuesForMountState() []string { + return []string{ + string(MountStateMountFailed), + string(MountStateMountRequested), + string(MountStateMounted), + string(MountStateUnmountFailed), + string(MountStateUnmountRequested), + string(MountStateUnmounted), + } +} + +func (s *MountState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMountState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMountState(input string) (*MountState, error) { + vals := map[string]MountState{ + "mountfailed": MountStateMountFailed, + "mountrequested": MountStateMountRequested, + "mounted": MountStateMounted, + "unmountfailed": MountStateUnmountFailed, + "unmountrequested": MountStateUnmountRequested, + "unmounted": MountStateUnmounted, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MountState(input) + return &out, nil +} + +type Network string + +const ( + NetworkBridge Network = "Bridge" + NetworkHost Network = "Host" +) + +func PossibleValuesForNetwork() []string { + return []string{ + string(NetworkBridge), + string(NetworkHost), + } +} + +func (s *Network) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNetwork(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNetwork(input string) (*Network, error) { + vals := map[string]Network{ + "bridge": NetworkBridge, + "host": NetworkHost, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Network(input) + return &out, nil +} + +type OperationName string + +const ( + OperationNameCreate OperationName = "Create" + OperationNameDelete OperationName = "Delete" + OperationNameReimage OperationName = "Reimage" + OperationNameRestart OperationName = "Restart" + OperationNameStart OperationName = "Start" + OperationNameStop OperationName = "Stop" +) + +func PossibleValuesForOperationName() []string { + return []string{ + string(OperationNameCreate), + string(OperationNameDelete), + string(OperationNameReimage), + string(OperationNameRestart), + string(OperationNameStart), + string(OperationNameStop), + } +} + +func (s *OperationName) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperationName(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOperationName(input string) (*OperationName, error) { + vals := map[string]OperationName{ + "create": OperationNameCreate, + "delete": OperationNameDelete, + "reimage": OperationNameReimage, + "restart": OperationNameRestart, + "start": OperationNameStart, + "stop": OperationNameStop, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OperationName(input) + return &out, nil +} + +type OperationStatus string + +const ( + OperationStatusCreateFailed OperationStatus = "CreateFailed" + OperationStatusDeleteFailed OperationStatus = "DeleteFailed" + OperationStatusInProgress OperationStatus = "InProgress" + OperationStatusReimageFailed OperationStatus = "ReimageFailed" + OperationStatusRestartFailed OperationStatus = "RestartFailed" + OperationStatusStartFailed OperationStatus = "StartFailed" + OperationStatusStopFailed OperationStatus = "StopFailed" + OperationStatusSucceeded OperationStatus = "Succeeded" +) + +func PossibleValuesForOperationStatus() []string { + return []string{ + string(OperationStatusCreateFailed), + string(OperationStatusDeleteFailed), + string(OperationStatusInProgress), + string(OperationStatusReimageFailed), + string(OperationStatusRestartFailed), + string(OperationStatusStartFailed), + string(OperationStatusStopFailed), + string(OperationStatusSucceeded), + } +} + +func (s *OperationStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperationStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOperationStatus(input string) (*OperationStatus, error) { + vals := map[string]OperationStatus{ + "createfailed": OperationStatusCreateFailed, + "deletefailed": OperationStatusDeleteFailed, + "inprogress": OperationStatusInProgress, + "reimagefailed": OperationStatusReimageFailed, + "restartfailed": OperationStatusRestartFailed, + "startfailed": OperationStatusStartFailed, + "stopfailed": OperationStatusStopFailed, + "succeeded": OperationStatusSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OperationStatus(input) + return &out, nil +} + +type OperationTrigger string + +const ( + OperationTriggerIdleShutdown OperationTrigger = "IdleShutdown" + OperationTriggerSchedule OperationTrigger = "Schedule" + OperationTriggerUser OperationTrigger = "User" +) + +func PossibleValuesForOperationTrigger() []string { + return []string{ + string(OperationTriggerIdleShutdown), + string(OperationTriggerSchedule), + string(OperationTriggerUser), + } +} + +func (s *OperationTrigger) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOperationTrigger(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOperationTrigger(input string) (*OperationTrigger, error) { + vals := map[string]OperationTrigger{ + "idleshutdown": OperationTriggerIdleShutdown, + "schedule": OperationTriggerSchedule, + "user": OperationTriggerUser, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OperationTrigger(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 ( + ProtocolHTTP Protocol = "http" + ProtocolTcp Protocol = "tcp" + ProtocolUdp Protocol = "udp" +) + +func PossibleValuesForProtocol() []string { + return []string{ + string(ProtocolHTTP), + 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{ + "http": ProtocolHTTP, + "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 ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type ProvisioningStatus string + +const ( + ProvisioningStatusCompleted ProvisioningStatus = "Completed" + ProvisioningStatusFailed ProvisioningStatus = "Failed" + ProvisioningStatusProvisioning ProvisioningStatus = "Provisioning" +) + +func PossibleValuesForProvisioningStatus() []string { + return []string{ + string(ProvisioningStatusCompleted), + string(ProvisioningStatusFailed), + string(ProvisioningStatusProvisioning), + } +} + +func (s *ProvisioningStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningStatus(input string) (*ProvisioningStatus, error) { + vals := map[string]ProvisioningStatus{ + "completed": ProvisioningStatusCompleted, + "failed": ProvisioningStatusFailed, + "provisioning": ProvisioningStatusProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningStatus(input) + return &out, nil +} + +type RemoteLoginPortPublicAccess string + +const ( + RemoteLoginPortPublicAccessDisabled RemoteLoginPortPublicAccess = "Disabled" + RemoteLoginPortPublicAccessEnabled RemoteLoginPortPublicAccess = "Enabled" + RemoteLoginPortPublicAccessNotSpecified RemoteLoginPortPublicAccess = "NotSpecified" +) + +func PossibleValuesForRemoteLoginPortPublicAccess() []string { + return []string{ + string(RemoteLoginPortPublicAccessDisabled), + string(RemoteLoginPortPublicAccessEnabled), + string(RemoteLoginPortPublicAccessNotSpecified), + } +} + +func (s *RemoteLoginPortPublicAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRemoteLoginPortPublicAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRemoteLoginPortPublicAccess(input string) (*RemoteLoginPortPublicAccess, error) { + vals := map[string]RemoteLoginPortPublicAccess{ + "disabled": RemoteLoginPortPublicAccessDisabled, + "enabled": RemoteLoginPortPublicAccessEnabled, + "notspecified": RemoteLoginPortPublicAccessNotSpecified, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RemoteLoginPortPublicAccess(input) + return &out, nil +} + +type ScheduleProvisioningState string + +const ( + ScheduleProvisioningStateCompleted ScheduleProvisioningState = "Completed" + ScheduleProvisioningStateFailed ScheduleProvisioningState = "Failed" + ScheduleProvisioningStateProvisioning ScheduleProvisioningState = "Provisioning" +) + +func PossibleValuesForScheduleProvisioningState() []string { + return []string{ + string(ScheduleProvisioningStateCompleted), + string(ScheduleProvisioningStateFailed), + string(ScheduleProvisioningStateProvisioning), + } +} + +func (s *ScheduleProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScheduleProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScheduleProvisioningState(input string) (*ScheduleProvisioningState, error) { + vals := map[string]ScheduleProvisioningState{ + "completed": ScheduleProvisioningStateCompleted, + "failed": ScheduleProvisioningStateFailed, + "provisioning": ScheduleProvisioningStateProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScheduleProvisioningState(input) + return &out, nil +} + +type ScheduleStatus string + +const ( + ScheduleStatusDisabled ScheduleStatus = "Disabled" + ScheduleStatusEnabled ScheduleStatus = "Enabled" +) + +func PossibleValuesForScheduleStatus() []string { + return []string{ + string(ScheduleStatusDisabled), + string(ScheduleStatusEnabled), + } +} + +func (s *ScheduleStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScheduleStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScheduleStatus(input string) (*ScheduleStatus, error) { + vals := map[string]ScheduleStatus{ + "disabled": ScheduleStatusDisabled, + "enabled": ScheduleStatusEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScheduleStatus(input) + return &out, nil +} + +type SkuTier string + +const ( + SkuTierBasic SkuTier = "Basic" + SkuTierFree SkuTier = "Free" + SkuTierPremium SkuTier = "Premium" + SkuTierStandard SkuTier = "Standard" +) + +func PossibleValuesForSkuTier() []string { + return []string{ + string(SkuTierBasic), + string(SkuTierFree), + string(SkuTierPremium), + string(SkuTierStandard), + } +} + +func (s *SkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuTier(input string) (*SkuTier, error) { + vals := map[string]SkuTier{ + "basic": SkuTierBasic, + "free": SkuTierFree, + "premium": SkuTierPremium, + "standard": SkuTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuTier(input) + return &out, nil +} + +type SourceType string + +const ( + SourceTypeDataset SourceType = "Dataset" + SourceTypeDatastore SourceType = "Datastore" + SourceTypeURI SourceType = "URI" +) + +func PossibleValuesForSourceType() []string { + return []string{ + string(SourceTypeDataset), + string(SourceTypeDatastore), + string(SourceTypeURI), + } +} + +func (s *SourceType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSourceType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSourceType(input string) (*SourceType, error) { + vals := map[string]SourceType{ + "dataset": SourceTypeDataset, + "datastore": SourceTypeDatastore, + "uri": SourceTypeURI, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SourceType(input) + return &out, nil +} + +type SshPublicAccess string + +const ( + SshPublicAccessDisabled SshPublicAccess = "Disabled" + SshPublicAccessEnabled SshPublicAccess = "Enabled" +) + +func PossibleValuesForSshPublicAccess() []string { + return []string{ + string(SshPublicAccessDisabled), + string(SshPublicAccessEnabled), + } +} + +func (s *SshPublicAccess) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSshPublicAccess(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSshPublicAccess(input string) (*SshPublicAccess, error) { + vals := map[string]SshPublicAccess{ + "disabled": SshPublicAccessDisabled, + "enabled": SshPublicAccessEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SshPublicAccess(input) + return &out, nil +} + +type SslConfigStatus string + +const ( + SslConfigStatusAuto SslConfigStatus = "Auto" + SslConfigStatusDisabled SslConfigStatus = "Disabled" + SslConfigStatusEnabled SslConfigStatus = "Enabled" +) + +func PossibleValuesForSslConfigStatus() []string { + return []string{ + string(SslConfigStatusAuto), + string(SslConfigStatusDisabled), + string(SslConfigStatusEnabled), + } +} + +func (s *SslConfigStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSslConfigStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSslConfigStatus(input string) (*SslConfigStatus, error) { + vals := map[string]SslConfigStatus{ + "auto": SslConfigStatusAuto, + "disabled": SslConfigStatusDisabled, + "enabled": SslConfigStatusEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SslConfigStatus(input) + return &out, nil +} + +type StorageAccountType string + +const ( + StorageAccountTypePremiumLRS StorageAccountType = "Premium_LRS" + StorageAccountTypeStandardLRS StorageAccountType = "Standard_LRS" +) + +func PossibleValuesForStorageAccountType() []string { + return []string{ + string(StorageAccountTypePremiumLRS), + string(StorageAccountTypeStandardLRS), + } +} + +func (s *StorageAccountType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStorageAccountType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStorageAccountType(input string) (*StorageAccountType, error) { + vals := map[string]StorageAccountType{ + "premium_lrs": StorageAccountTypePremiumLRS, + "standard_lrs": StorageAccountTypeStandardLRS, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StorageAccountType(input) + return &out, nil +} + +type UnderlyingResourceAction string + +const ( + UnderlyingResourceActionDelete UnderlyingResourceAction = "Delete" + UnderlyingResourceActionDetach UnderlyingResourceAction = "Detach" +) + +func PossibleValuesForUnderlyingResourceAction() []string { + return []string{ + string(UnderlyingResourceActionDelete), + string(UnderlyingResourceActionDetach), + } +} + +func (s *UnderlyingResourceAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUnderlyingResourceAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUnderlyingResourceAction(input string) (*UnderlyingResourceAction, error) { + vals := map[string]UnderlyingResourceAction{ + "delete": UnderlyingResourceActionDelete, + "detach": UnderlyingResourceActionDetach, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UnderlyingResourceAction(input) + return &out, nil +} + +type VMPriority string + +const ( + VMPriorityDedicated VMPriority = "Dedicated" + VMPriorityLowPriority VMPriority = "LowPriority" +) + +func PossibleValuesForVMPriority() []string { + return []string{ + string(VMPriorityDedicated), + string(VMPriorityLowPriority), + } +} + +func (s *VMPriority) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVMPriority(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVMPriority(input string) (*VMPriority, error) { + vals := map[string]VMPriority{ + "dedicated": VMPriorityDedicated, + "lowpriority": VMPriorityLowPriority, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VMPriority(input) + return &out, nil +} + +type VolumeDefinitionType string + +const ( + VolumeDefinitionTypeBind VolumeDefinitionType = "bind" + VolumeDefinitionTypeNpipe VolumeDefinitionType = "npipe" + VolumeDefinitionTypeTmpfs VolumeDefinitionType = "tmpfs" + VolumeDefinitionTypeVolume VolumeDefinitionType = "volume" +) + +func PossibleValuesForVolumeDefinitionType() []string { + return []string{ + string(VolumeDefinitionTypeBind), + string(VolumeDefinitionTypeNpipe), + string(VolumeDefinitionTypeTmpfs), + string(VolumeDefinitionTypeVolume), + } +} + +func (s *VolumeDefinitionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVolumeDefinitionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVolumeDefinitionType(input string) (*VolumeDefinitionType, error) { + vals := map[string]VolumeDefinitionType{ + "bind": VolumeDefinitionTypeBind, + "npipe": VolumeDefinitionTypeNpipe, + "tmpfs": VolumeDefinitionTypeTmpfs, + "volume": VolumeDefinitionTypeVolume, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VolumeDefinitionType(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/id_compute.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/id_compute.go new file mode 100644 index 00000000000..cacf7264d51 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/id_compute.go @@ -0,0 +1,139 @@ +package operationalizationclusters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ComputeId{}) +} + +var _ resourceids.ResourceId = &ComputeId{} + +// ComputeId is a struct representing the Resource ID for a Compute +type ComputeId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + ComputeName string +} + +// NewComputeID returns a new ComputeId struct +func NewComputeID(subscriptionId string, resourceGroupName string, workspaceName string, computeName string) ComputeId { + return ComputeId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + ComputeName: computeName, + } +} + +// ParseComputeID parses 'input' into a ComputeId +func ParseComputeID(input string) (*ComputeId, error) { + parser := resourceids.NewParserFromResourceIdType(&ComputeId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ComputeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseComputeIDInsensitively parses 'input' case-insensitively into a ComputeId +// note: this method should only be used for API response data and not user input +func ParseComputeIDInsensitively(input string) (*ComputeId, error) { + parser := resourceids.NewParserFromResourceIdType(&ComputeId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ComputeId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ComputeId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.ComputeName, ok = input.Parsed["computeName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "computeName", input) + } + + return nil +} + +// ValidateComputeID checks that 'input' can be parsed as a Compute ID +func ValidateComputeID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseComputeID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Compute ID +func (id ComputeId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/computes/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.ComputeName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Compute ID +func (id ComputeId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticComputes", "computes", "computes"), + resourceids.UserSpecifiedSegment("computeName", "computeName"), + } +} + +// String returns a human-readable description of this Compute ID +func (id ComputeId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Compute Name: %q", id.ComputeName), + } + return fmt.Sprintf("Compute (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/id_compute_test.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/id_compute_test.go new file mode 100644 index 00000000000..f00966a0329 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/id_compute_test.go @@ -0,0 +1,327 @@ +package operationalizationclusters + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ComputeId{} + +func TestNewComputeID(t *testing.T) { + id := NewComputeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "computeName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.ComputeName != "computeName" { + t.Fatalf("Expected %q but got %q for Segment 'ComputeName'", id.ComputeName, "computeName") + } +} + +func TestFormatComputeID(t *testing.T) { + actual := NewComputeID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "computeName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/computes/computeName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseComputeID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ComputeId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/computes", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/computes/computeName", + Expected: &ComputeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + ComputeName: "computeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/computes/computeName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseComputeID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.ComputeName != v.Expected.ComputeName { + t.Fatalf("Expected %q but got %q for ComputeName", v.Expected.ComputeName, actual.ComputeName) + } + + } +} + +func TestParseComputeIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ComputeId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/computes", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOmPuTeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/computes/computeName", + Expected: &ComputeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + ComputeName: "computeName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/computes/computeName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOmPuTeS/cOmPuTeNaMe", + Expected: &ComputeId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + ComputeName: "cOmPuTeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOmPuTeS/cOmPuTeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseComputeIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.ComputeName != v.Expected.ComputeName { + t.Fatalf("Expected %q but got %q for ComputeName", v.Expected.ComputeName, actual.ComputeName) + } + + } +} + +func TestSegmentsForComputeId(t *testing.T) { + segments := ComputeId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ComputeId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/id_workspace.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/id_workspace.go new file mode 100644 index 00000000000..b9572594d61 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/id_workspace.go @@ -0,0 +1,130 @@ +package operationalizationclusters + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/id_workspace_test.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/id_workspace_test.go new file mode 100644 index 00000000000..128cb4c28aa --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/id_workspace_test.go @@ -0,0 +1,282 @@ +package operationalizationclusters + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computecreateorupdate.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computecreateorupdate.go new file mode 100644 index 00000000000..aaf48c34655 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computecreateorupdate.go @@ -0,0 +1,75 @@ +package operationalizationclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ComputeResource +} + +// ComputeCreateOrUpdate ... +func (c OperationalizationClustersClient) ComputeCreateOrUpdate(ctx context.Context, id ComputeId, input ComputeResource) (result ComputeCreateOrUpdateOperationResponse, 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 +} + +// ComputeCreateOrUpdateThenPoll performs ComputeCreateOrUpdate then polls until it's completed +func (c OperationalizationClustersClient) ComputeCreateOrUpdateThenPoll(ctx context.Context, id ComputeId, input ComputeResource) error { + result, err := c.ComputeCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ComputeCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ComputeCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computedelete.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computedelete.go new file mode 100644 index 00000000000..d46fe834b40 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computedelete.go @@ -0,0 +1,100 @@ +package operationalizationclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +type ComputeDeleteOperationOptions struct { + UnderlyingResourceAction *UnderlyingResourceAction +} + +func DefaultComputeDeleteOperationOptions() ComputeDeleteOperationOptions { + return ComputeDeleteOperationOptions{} +} + +func (o ComputeDeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ComputeDeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ComputeDeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.UnderlyingResourceAction != nil { + out.Append("underlyingResourceAction", fmt.Sprintf("%v", *o.UnderlyingResourceAction)) + } + return &out +} + +// ComputeDelete ... +func (c OperationalizationClustersClient) ComputeDelete(ctx context.Context, id ComputeId, options ComputeDeleteOperationOptions) (result ComputeDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ComputeDeleteThenPoll performs ComputeDelete then polls until it's completed +func (c OperationalizationClustersClient) ComputeDeleteThenPoll(ctx context.Context, id ComputeId, options ComputeDeleteOperationOptions) error { + result, err := c.ComputeDelete(ctx, id, options) + if err != nil { + return fmt.Errorf("performing ComputeDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ComputeDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computeget.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computeget.go new file mode 100644 index 00000000000..c0ce1ba6495 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computeget.go @@ -0,0 +1,53 @@ +package operationalizationclusters + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ComputeResource +} + +// ComputeGet ... +func (c OperationalizationClustersClient) ComputeGet(ctx context.Context, id ComputeId) (result ComputeGetOperationResponse, 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 ComputeResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computelist.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computelist.go new file mode 100644 index 00000000000..38b0660ec9d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computelist.go @@ -0,0 +1,134 @@ +package operationalizationclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]ComputeResource +} + +type ComputeListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ComputeResource +} + +type ComputeListOperationOptions struct { + Skip *string +} + +func DefaultComputeListOperationOptions() ComputeListOperationOptions { + return ComputeListOperationOptions{} +} + +func (o ComputeListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ComputeListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ComputeListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + return &out +} + +type ComputeListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ComputeListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ComputeList ... +func (c OperationalizationClustersClient) ComputeList(ctx context.Context, id WorkspaceId, options ComputeListOperationOptions) (result ComputeListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ComputeListCustomPager{}, + Path: fmt.Sprintf("%s/computes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ComputeResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ComputeListComplete retrieves all the results into a single object +func (c OperationalizationClustersClient) ComputeListComplete(ctx context.Context, id WorkspaceId, options ComputeListOperationOptions) (ComputeListCompleteResult, error) { + return c.ComputeListCompleteMatchingPredicate(ctx, id, options, ComputeResourceOperationPredicate{}) +} + +// ComputeListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c OperationalizationClustersClient) ComputeListCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, options ComputeListOperationOptions, predicate ComputeResourceOperationPredicate) (result ComputeListCompleteResult, err error) { + items := make([]ComputeResource, 0) + + resp, err := c.ComputeList(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 = ComputeListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computelistkeys.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computelistkeys.go new file mode 100644 index 00000000000..c1e42e81440 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computelistkeys.go @@ -0,0 +1,59 @@ +package operationalizationclusters + +import ( + "context" + "encoding/json" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeListKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model ComputeSecrets +} + +// ComputeListKeys ... +func (c OperationalizationClustersClient) ComputeListKeys(ctx context.Context, id ComputeId) (result ComputeListKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var respObj json.RawMessage + if err = resp.Unmarshal(&respObj); err != nil { + return + } + model, err := UnmarshalComputeSecretsImplementation(respObj) + if err != nil { + return + } + result.Model = model + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computerestart.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computerestart.go new file mode 100644 index 00000000000..58a901cfc05 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computerestart.go @@ -0,0 +1,69 @@ +package operationalizationclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeRestartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ComputeRestart ... +func (c OperationalizationClustersClient) ComputeRestart(ctx context.Context, id ComputeId) (result ComputeRestartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/restart", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ComputeRestartThenPoll performs ComputeRestart then polls until it's completed +func (c OperationalizationClustersClient) ComputeRestartThenPoll(ctx context.Context, id ComputeId) error { + result, err := c.ComputeRestart(ctx, id) + if err != nil { + return fmt.Errorf("performing ComputeRestart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ComputeRestart: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computestart.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computestart.go new file mode 100644 index 00000000000..7f6ee5a2043 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computestart.go @@ -0,0 +1,69 @@ +package operationalizationclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeStartOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ComputeStart ... +func (c OperationalizationClustersClient) ComputeStart(ctx context.Context, id ComputeId) (result ComputeStartOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/start", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ComputeStartThenPoll performs ComputeStart then polls until it's completed +func (c OperationalizationClustersClient) ComputeStartThenPoll(ctx context.Context, id ComputeId) error { + result, err := c.ComputeStart(ctx, id) + if err != nil { + return fmt.Errorf("performing ComputeStart: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ComputeStart: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computestop.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computestop.go new file mode 100644 index 00000000000..b8960ae11db --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computestop.go @@ -0,0 +1,69 @@ +package operationalizationclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeStopOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ComputeStop ... +func (c OperationalizationClustersClient) ComputeStop(ctx context.Context, id ComputeId) (result ComputeStopOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + }, + 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 +} + +// ComputeStopThenPoll performs ComputeStop then polls until it's completed +func (c OperationalizationClustersClient) ComputeStopThenPoll(ctx context.Context, id ComputeId) error { + result, err := c.ComputeStop(ctx, id) + if err != nil { + return fmt.Errorf("performing ComputeStop: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ComputeStop: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computeupdate.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computeupdate.go new file mode 100644 index 00000000000..caf53a24481 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/method_computeupdate.go @@ -0,0 +1,74 @@ +package operationalizationclusters + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *ComputeResource +} + +// ComputeUpdate ... +func (c OperationalizationClustersClient) ComputeUpdate(ctx context.Context, id ComputeId, input ClusterUpdateParameters) (result ComputeUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPatch, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ComputeUpdateThenPoll performs ComputeUpdate then polls until it's completed +func (c OperationalizationClustersClient) ComputeUpdateThenPoll(ctx context.Context, id ComputeId, input ClusterUpdateParameters) error { + result, err := c.ComputeUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing ComputeUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ComputeUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_aks.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_aks.go new file mode 100644 index 00000000000..d9368b9a2c1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_aks.go @@ -0,0 +1,95 @@ +package operationalizationclusters + +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. + +var _ Compute = AKS{} + +type AKS struct { + Properties *AKSSchemaProperties `json:"properties,omitempty"` + + // Fields inherited from Compute + + ComputeLocation *string `json:"computeLocation,omitempty"` + ComputeType ComputeType `json:"computeType"` + CreatedOn *string `json:"createdOn,omitempty"` + Description *string `json:"description,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + IsAttachedCompute *bool `json:"isAttachedCompute,omitempty"` + ModifiedOn *string `json:"modifiedOn,omitempty"` + ProvisioningErrors *[]ErrorResponse `json:"provisioningErrors,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} + +func (s AKS) Compute() BaseComputeImpl { + return BaseComputeImpl{ + ComputeLocation: s.ComputeLocation, + ComputeType: s.ComputeType, + CreatedOn: s.CreatedOn, + Description: s.Description, + DisableLocalAuth: s.DisableLocalAuth, + IsAttachedCompute: s.IsAttachedCompute, + ModifiedOn: s.ModifiedOn, + ProvisioningErrors: s.ProvisioningErrors, + ProvisioningState: s.ProvisioningState, + ResourceId: s.ResourceId, + } +} + +func (o *AKS) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *AKS) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} + +func (o *AKS) GetModifiedOnAsTime() (*time.Time, error) { + if o.ModifiedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *AKS) SetModifiedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedOn = &formatted +} + +var _ json.Marshaler = AKS{} + +func (s AKS) MarshalJSON() ([]byte, error) { + type wrapper AKS + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AKS: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AKS: %+v", err) + } + + decoded["computeType"] = "AKS" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AKS: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_akscomputesecrets.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_akscomputesecrets.go new file mode 100644 index 00000000000..319acdc49ad --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_akscomputesecrets.go @@ -0,0 +1,52 @@ +package operationalizationclusters + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ComputeSecrets = AksComputeSecrets{} + +type AksComputeSecrets struct { + AdminKubeConfig *string `json:"adminKubeConfig,omitempty"` + ImagePullSecretName *string `json:"imagePullSecretName,omitempty"` + UserKubeConfig *string `json:"userKubeConfig,omitempty"` + + // Fields inherited from ComputeSecrets + + ComputeType ComputeType `json:"computeType"` +} + +func (s AksComputeSecrets) ComputeSecrets() BaseComputeSecretsImpl { + return BaseComputeSecretsImpl{ + ComputeType: s.ComputeType, + } +} + +var _ json.Marshaler = AksComputeSecrets{} + +func (s AksComputeSecrets) MarshalJSON() ([]byte, error) { + type wrapper AksComputeSecrets + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AksComputeSecrets: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AksComputeSecrets: %+v", err) + } + + decoded["computeType"] = "AKS" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AksComputeSecrets: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_aksnetworkingconfiguration.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_aksnetworkingconfiguration.go new file mode 100644 index 00000000000..85a370006f5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_aksnetworkingconfiguration.go @@ -0,0 +1,11 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AksNetworkingConfiguration struct { + DnsServiceIP *string `json:"dnsServiceIP,omitempty"` + DockerBridgeCidr *string `json:"dockerBridgeCidr,omitempty"` + ServiceCidr *string `json:"serviceCidr,omitempty"` + SubnetId *string `json:"subnetId,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_aksschemaproperties.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_aksschemaproperties.go new file mode 100644 index 00000000000..962b1440585 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_aksschemaproperties.go @@ -0,0 +1,16 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AKSSchemaProperties struct { + AgentCount *int64 `json:"agentCount,omitempty"` + AgentVMSize *string `json:"agentVmSize,omitempty"` + AksNetworkingConfiguration *AksNetworkingConfiguration `json:"aksNetworkingConfiguration,omitempty"` + ClusterFqdn *string `json:"clusterFqdn,omitempty"` + ClusterPurpose *ClusterPurpose `json:"clusterPurpose,omitempty"` + LoadBalancerSubnet *string `json:"loadBalancerSubnet,omitempty"` + LoadBalancerType *LoadBalancerType `json:"loadBalancerType,omitempty"` + SslConfiguration *SslConfiguration `json:"sslConfiguration,omitempty"` + SystemServices *[]SystemService `json:"systemServices,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_amlcompute.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_amlcompute.go new file mode 100644 index 00000000000..7d90546a442 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_amlcompute.go @@ -0,0 +1,95 @@ +package operationalizationclusters + +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. + +var _ Compute = AmlCompute{} + +type AmlCompute struct { + Properties *AmlComputeProperties `json:"properties,omitempty"` + + // Fields inherited from Compute + + ComputeLocation *string `json:"computeLocation,omitempty"` + ComputeType ComputeType `json:"computeType"` + CreatedOn *string `json:"createdOn,omitempty"` + Description *string `json:"description,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + IsAttachedCompute *bool `json:"isAttachedCompute,omitempty"` + ModifiedOn *string `json:"modifiedOn,omitempty"` + ProvisioningErrors *[]ErrorResponse `json:"provisioningErrors,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} + +func (s AmlCompute) Compute() BaseComputeImpl { + return BaseComputeImpl{ + ComputeLocation: s.ComputeLocation, + ComputeType: s.ComputeType, + CreatedOn: s.CreatedOn, + Description: s.Description, + DisableLocalAuth: s.DisableLocalAuth, + IsAttachedCompute: s.IsAttachedCompute, + ModifiedOn: s.ModifiedOn, + ProvisioningErrors: s.ProvisioningErrors, + ProvisioningState: s.ProvisioningState, + ResourceId: s.ResourceId, + } +} + +func (o *AmlCompute) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *AmlCompute) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} + +func (o *AmlCompute) GetModifiedOnAsTime() (*time.Time, error) { + if o.ModifiedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *AmlCompute) SetModifiedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedOn = &formatted +} + +var _ json.Marshaler = AmlCompute{} + +func (s AmlCompute) MarshalJSON() ([]byte, error) { + type wrapper AmlCompute + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AmlCompute: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AmlCompute: %+v", err) + } + + decoded["computeType"] = "AmlCompute" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AmlCompute: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_amlcomputeproperties.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_amlcomputeproperties.go new file mode 100644 index 00000000000..b3177b61529 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_amlcomputeproperties.go @@ -0,0 +1,42 @@ +package operationalizationclusters + +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 AmlComputeProperties struct { + AllocationState *AllocationState `json:"allocationState,omitempty"` + AllocationStateTransitionTime *string `json:"allocationStateTransitionTime,omitempty"` + CurrentNodeCount *int64 `json:"currentNodeCount,omitempty"` + EnableNodePublicIP *bool `json:"enableNodePublicIp,omitempty"` + Errors *[]ErrorResponse `json:"errors,omitempty"` + IsolatedNetwork *bool `json:"isolatedNetwork,omitempty"` + NodeStateCounts *NodeStateCounts `json:"nodeStateCounts,omitempty"` + OsType *OsType `json:"osType,omitempty"` + PropertyBag *interface{} `json:"propertyBag,omitempty"` + RemoteLoginPortPublicAccess *RemoteLoginPortPublicAccess `json:"remoteLoginPortPublicAccess,omitempty"` + ScaleSettings *ScaleSettings `json:"scaleSettings,omitempty"` + Subnet *ResourceId `json:"subnet,omitempty"` + TargetNodeCount *int64 `json:"targetNodeCount,omitempty"` + UserAccountCredentials *UserAccountCredentials `json:"userAccountCredentials,omitempty"` + VMPriority *VMPriority `json:"vmPriority,omitempty"` + VMSize *string `json:"vmSize,omitempty"` + VirtualMachineImage *VirtualMachineImage `json:"virtualMachineImage,omitempty"` +} + +func (o *AmlComputeProperties) GetAllocationStateTransitionTimeAsTime() (*time.Time, error) { + if o.AllocationStateTransitionTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.AllocationStateTransitionTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AmlComputeProperties) SetAllocationStateTransitionTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.AllocationStateTransitionTime = &formatted +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_assigneduser.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_assigneduser.go new file mode 100644 index 00000000000..3512b5a08a3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_assigneduser.go @@ -0,0 +1,9 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AssignedUser struct { + ObjectId string `json:"objectId"` + TenantId string `json:"tenantId"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_autopauseproperties.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_autopauseproperties.go new file mode 100644 index 00000000000..fd3b934b0c9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_autopauseproperties.go @@ -0,0 +1,9 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoPauseProperties struct { + DelayInMinutes *int64 `json:"delayInMinutes,omitempty"` + Enabled *bool `json:"enabled,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_autoscaleproperties.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_autoscaleproperties.go new file mode 100644 index 00000000000..c186aca5970 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_autoscaleproperties.go @@ -0,0 +1,10 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AutoScaleProperties struct { + Enabled *bool `json:"enabled,omitempty"` + MaxNodeCount *int64 `json:"maxNodeCount,omitempty"` + MinNodeCount *int64 `json:"minNodeCount,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_bindoptions.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_bindoptions.go new file mode 100644 index 00000000000..d9cd0246531 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_bindoptions.go @@ -0,0 +1,10 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type BindOptions struct { + CreateHostPath *bool `json:"createHostPath,omitempty"` + Propagation *string `json:"propagation,omitempty"` + Selinux *string `json:"selinux,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_clusterupdateparameters.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_clusterupdateparameters.go new file mode 100644 index 00000000000..66df241baf3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_clusterupdateparameters.go @@ -0,0 +1,8 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterUpdateParameters struct { + Properties *ClusterUpdateProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_clusterupdateproperties.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_clusterupdateproperties.go new file mode 100644 index 00000000000..1709e67c9b3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_clusterupdateproperties.go @@ -0,0 +1,8 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClusterUpdateProperties struct { + Properties *ScaleSettingsInformation `json:"properties,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_compute.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_compute.go new file mode 100644 index 00000000000..8de7a1d52ee --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_compute.go @@ -0,0 +1,156 @@ +package operationalizationclusters + +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 Compute interface { + Compute() BaseComputeImpl +} + +var _ Compute = BaseComputeImpl{} + +type BaseComputeImpl struct { + ComputeLocation *string `json:"computeLocation,omitempty"` + ComputeType ComputeType `json:"computeType"` + CreatedOn *string `json:"createdOn,omitempty"` + Description *string `json:"description,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + IsAttachedCompute *bool `json:"isAttachedCompute,omitempty"` + ModifiedOn *string `json:"modifiedOn,omitempty"` + ProvisioningErrors *[]ErrorResponse `json:"provisioningErrors,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} + +func (s BaseComputeImpl) Compute() BaseComputeImpl { + return s +} + +var _ Compute = RawComputeImpl{} + +// RawComputeImpl 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 RawComputeImpl struct { + compute BaseComputeImpl + Type string + Values map[string]interface{} +} + +func (s RawComputeImpl) Compute() BaseComputeImpl { + return s.compute +} + +func UnmarshalComputeImplementation(input []byte) (Compute, 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 Compute into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["computeType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AKS") { + var out AKS + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AKS: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AmlCompute") { + var out AmlCompute + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AmlCompute: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ComputeInstance") { + var out ComputeInstance + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ComputeInstance: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DataFactory") { + var out DataFactory + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DataFactory: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DataLakeAnalytics") { + var out DataLakeAnalytics + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DataLakeAnalytics: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Databricks") { + var out Databricks + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into Databricks: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "HDInsight") { + var out HDInsight + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into HDInsight: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Kubernetes") { + var out Kubernetes + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into Kubernetes: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SynapseSpark") { + var out SynapseSpark + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SynapseSpark: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VirtualMachine") { + var out VirtualMachine + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VirtualMachine: %+v", err) + } + return out, nil + } + + var parent BaseComputeImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseComputeImpl: %+v", err) + } + + return RawComputeImpl{ + compute: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstance.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstance.go new file mode 100644 index 00000000000..27962037197 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstance.go @@ -0,0 +1,95 @@ +package operationalizationclusters + +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. + +var _ Compute = ComputeInstance{} + +type ComputeInstance struct { + Properties *ComputeInstanceProperties `json:"properties,omitempty"` + + // Fields inherited from Compute + + ComputeLocation *string `json:"computeLocation,omitempty"` + ComputeType ComputeType `json:"computeType"` + CreatedOn *string `json:"createdOn,omitempty"` + Description *string `json:"description,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + IsAttachedCompute *bool `json:"isAttachedCompute,omitempty"` + ModifiedOn *string `json:"modifiedOn,omitempty"` + ProvisioningErrors *[]ErrorResponse `json:"provisioningErrors,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} + +func (s ComputeInstance) Compute() BaseComputeImpl { + return BaseComputeImpl{ + ComputeLocation: s.ComputeLocation, + ComputeType: s.ComputeType, + CreatedOn: s.CreatedOn, + Description: s.Description, + DisableLocalAuth: s.DisableLocalAuth, + IsAttachedCompute: s.IsAttachedCompute, + ModifiedOn: s.ModifiedOn, + ProvisioningErrors: s.ProvisioningErrors, + ProvisioningState: s.ProvisioningState, + ResourceId: s.ResourceId, + } +} + +func (o *ComputeInstance) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *ComputeInstance) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} + +func (o *ComputeInstance) GetModifiedOnAsTime() (*time.Time, error) { + if o.ModifiedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *ComputeInstance) SetModifiedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedOn = &formatted +} + +var _ json.Marshaler = ComputeInstance{} + +func (s ComputeInstance) MarshalJSON() ([]byte, error) { + type wrapper ComputeInstance + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ComputeInstance: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ComputeInstance: %+v", err) + } + + decoded["computeType"] = "ComputeInstance" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ComputeInstance: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstanceapplication.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstanceapplication.go new file mode 100644 index 00000000000..18593da9ce6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstanceapplication.go @@ -0,0 +1,9 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeInstanceApplication struct { + DisplayName *string `json:"displayName,omitempty"` + EndpointUri *string `json:"endpointUri,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstanceconnectivityendpoints.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstanceconnectivityendpoints.go new file mode 100644 index 00000000000..816c22eb23e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstanceconnectivityendpoints.go @@ -0,0 +1,9 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeInstanceConnectivityEndpoints struct { + PrivateIPAddress *string `json:"privateIpAddress,omitempty"` + PublicIPAddress *string `json:"publicIpAddress,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstancecontainer.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstancecontainer.go new file mode 100644 index 00000000000..499ea674c12 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstancecontainer.go @@ -0,0 +1,13 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeInstanceContainer struct { + Autosave *Autosave `json:"autosave,omitempty"` + Environment *ComputeInstanceEnvironmentInfo `json:"environment,omitempty"` + Gpu *string `json:"gpu,omitempty"` + Name *string `json:"name,omitempty"` + Network *Network `json:"network,omitempty"` + Services *[]interface{} `json:"services,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstancecreatedby.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstancecreatedby.go new file mode 100644 index 00000000000..64c6acef2d1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstancecreatedby.go @@ -0,0 +1,10 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeInstanceCreatedBy struct { + UserId *string `json:"userId,omitempty"` + UserName *string `json:"userName,omitempty"` + UserOrgId *string `json:"userOrgId,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstancedatadisk.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstancedatadisk.go new file mode 100644 index 00000000000..e38bd919417 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstancedatadisk.go @@ -0,0 +1,11 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeInstanceDataDisk struct { + Caching *Caching `json:"caching,omitempty"` + DiskSizeGB *int64 `json:"diskSizeGB,omitempty"` + Lun *int64 `json:"lun,omitempty"` + StorageAccountType *StorageAccountType `json:"storageAccountType,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstancedatamount.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstancedatamount.go new file mode 100644 index 00000000000..71cdf57ec58 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstancedatamount.go @@ -0,0 +1,34 @@ +package operationalizationclusters + +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 ComputeInstanceDataMount struct { + CreatedBy *string `json:"createdBy,omitempty"` + Error *string `json:"error,omitempty"` + MountAction *MountAction `json:"mountAction,omitempty"` + MountName *string `json:"mountName,omitempty"` + MountPath *string `json:"mountPath,omitempty"` + MountState *MountState `json:"mountState,omitempty"` + MountedOn *string `json:"mountedOn,omitempty"` + Source *string `json:"source,omitempty"` + SourceType *SourceType `json:"sourceType,omitempty"` +} + +func (o *ComputeInstanceDataMount) GetMountedOnAsTime() (*time.Time, error) { + if o.MountedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.MountedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *ComputeInstanceDataMount) SetMountedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.MountedOn = &formatted +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstanceenvironmentinfo.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstanceenvironmentinfo.go new file mode 100644 index 00000000000..0a1da98483a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstanceenvironmentinfo.go @@ -0,0 +1,9 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeInstanceEnvironmentInfo struct { + Name *string `json:"name,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstancelastoperation.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstancelastoperation.go new file mode 100644 index 00000000000..b17e9145be6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstancelastoperation.go @@ -0,0 +1,29 @@ +package operationalizationclusters + +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 ComputeInstanceLastOperation struct { + OperationName *OperationName `json:"operationName,omitempty"` + OperationStatus *OperationStatus `json:"operationStatus,omitempty"` + OperationTime *string `json:"operationTime,omitempty"` + OperationTrigger *OperationTrigger `json:"operationTrigger,omitempty"` +} + +func (o *ComputeInstanceLastOperation) GetOperationTimeAsTime() (*time.Time, error) { + if o.OperationTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.OperationTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ComputeInstanceLastOperation) SetOperationTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.OperationTime = &formatted +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstanceproperties.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstanceproperties.go new file mode 100644 index 00000000000..955b98f2a36 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstanceproperties.go @@ -0,0 +1,28 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeInstanceProperties struct { + ApplicationSharingPolicy *ApplicationSharingPolicy `json:"applicationSharingPolicy,omitempty"` + Applications *[]ComputeInstanceApplication `json:"applications,omitempty"` + ComputeInstanceAuthorizationType *ComputeInstanceAuthorizationType `json:"computeInstanceAuthorizationType,omitempty"` + ConnectivityEndpoints *ComputeInstanceConnectivityEndpoints `json:"connectivityEndpoints,omitempty"` + Containers *[]ComputeInstanceContainer `json:"containers,omitempty"` + CreatedBy *ComputeInstanceCreatedBy `json:"createdBy,omitempty"` + CustomServices *[]CustomService `json:"customServices,omitempty"` + DataDisks *[]ComputeInstanceDataDisk `json:"dataDisks,omitempty"` + DataMounts *[]ComputeInstanceDataMount `json:"dataMounts,omitempty"` + EnableNodePublicIP *bool `json:"enableNodePublicIp,omitempty"` + Errors *[]ErrorResponse `json:"errors,omitempty"` + LastOperation *ComputeInstanceLastOperation `json:"lastOperation,omitempty"` + OsImageMetadata *ImageMetadata `json:"osImageMetadata,omitempty"` + PersonalComputeInstanceSettings *PersonalComputeInstanceSettings `json:"personalComputeInstanceSettings,omitempty"` + Schedules *ComputeSchedules `json:"schedules,omitempty"` + SetupScripts *SetupScripts `json:"setupScripts,omitempty"` + SshSettings *ComputeInstanceSshSettings `json:"sshSettings,omitempty"` + State *ComputeInstanceState `json:"state,omitempty"` + Subnet *ResourceId `json:"subnet,omitempty"` + VMSize *string `json:"vmSize,omitempty"` + Versions *ComputeInstanceVersion `json:"versions,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstancesshsettings.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstancesshsettings.go new file mode 100644 index 00000000000..3d82be6ffe0 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstancesshsettings.go @@ -0,0 +1,11 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeInstanceSshSettings struct { + AdminPublicKey *string `json:"adminPublicKey,omitempty"` + AdminUserName *string `json:"adminUserName,omitempty"` + SshPort *int64 `json:"sshPort,omitempty"` + SshPublicAccess *SshPublicAccess `json:"sshPublicAccess,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstanceversion.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstanceversion.go new file mode 100644 index 00000000000..faa620d0920 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeinstanceversion.go @@ -0,0 +1,8 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeInstanceVersion struct { + Runtime *string `json:"runtime,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computerecurrenceschedule.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computerecurrenceschedule.go new file mode 100644 index 00000000000..fdfe252a8ae --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computerecurrenceschedule.go @@ -0,0 +1,11 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeRecurrenceSchedule struct { + Hours []int64 `json:"hours"` + Minutes []int64 `json:"minutes"` + MonthDays *[]int64 `json:"monthDays,omitempty"` + WeekDays *[]ComputeWeekDay `json:"weekDays,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeresource.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeresource.go new file mode 100644 index 00000000000..e1a002540df --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeresource.go @@ -0,0 +1,66 @@ +package operationalizationclusters + +import ( + "encoding/json" + "fmt" + + "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 ComputeResource struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties Compute `json:"properties"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &ComputeResource{} + +func (s *ComputeResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Id = decoded.Id + s.Identity = decoded.Identity + s.Location = decoded.Location + s.Name = decoded.Name + s.Sku = decoded.Sku + s.SystemData = decoded.SystemData + s.Tags = decoded.Tags + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ComputeResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalComputeImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'ComputeResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeschedules.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeschedules.go new file mode 100644 index 00000000000..5352753cde6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computeschedules.go @@ -0,0 +1,8 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeSchedules struct { + ComputeStartStop *[]ComputeStartStopSchedule `json:"computeStartStop,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computesecrets.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computesecrets.go new file mode 100644 index 00000000000..78faa2d0345 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computesecrets.go @@ -0,0 +1,91 @@ +package operationalizationclusters + +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 ComputeSecrets interface { + ComputeSecrets() BaseComputeSecretsImpl +} + +var _ ComputeSecrets = BaseComputeSecretsImpl{} + +type BaseComputeSecretsImpl struct { + ComputeType ComputeType `json:"computeType"` +} + +func (s BaseComputeSecretsImpl) ComputeSecrets() BaseComputeSecretsImpl { + return s +} + +var _ ComputeSecrets = RawComputeSecretsImpl{} + +// RawComputeSecretsImpl 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 RawComputeSecretsImpl struct { + computeSecrets BaseComputeSecretsImpl + Type string + Values map[string]interface{} +} + +func (s RawComputeSecretsImpl) ComputeSecrets() BaseComputeSecretsImpl { + return s.computeSecrets +} + +func UnmarshalComputeSecretsImplementation(input []byte) (ComputeSecrets, 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 ComputeSecrets into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["computeType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AKS") { + var out AksComputeSecrets + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AksComputeSecrets: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Databricks") { + var out DatabricksComputeSecrets + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DatabricksComputeSecrets: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "VirtualMachine") { + var out VirtualMachineSecrets + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into VirtualMachineSecrets: %+v", err) + } + return out, nil + } + + var parent BaseComputeSecretsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseComputeSecretsImpl: %+v", err) + } + + return RawComputeSecretsImpl{ + computeSecrets: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computestartstopschedule.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computestartstopschedule.go new file mode 100644 index 00000000000..def3ab07023 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_computestartstopschedule.go @@ -0,0 +1,15 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeStartStopSchedule struct { + Action *ComputePowerAction `json:"action,omitempty"` + Cron *Cron `json:"cron,omitempty"` + Id *string `json:"id,omitempty"` + ProvisioningStatus *ProvisioningStatus `json:"provisioningStatus,omitempty"` + Recurrence *Recurrence `json:"recurrence,omitempty"` + Schedule *ScheduleBase `json:"schedule,omitempty"` + Status *ScheduleStatus `json:"status,omitempty"` + TriggerType *ComputeTriggerType `json:"triggerType,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_cron.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_cron.go new file mode 100644 index 00000000000..56a96dd34a9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_cron.go @@ -0,0 +1,10 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Cron struct { + Expression *string `json:"expression,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_customservice.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_customservice.go new file mode 100644 index 00000000000..273dd6eb562 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_customservice.go @@ -0,0 +1,13 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomService struct { + Docker *Docker `json:"docker,omitempty"` + Endpoints *[]Endpoint `json:"endpoints,omitempty"` + EnvironmentVariables *map[string]EnvironmentVariable `json:"environmentVariables,omitempty"` + Image *Image `json:"image,omitempty"` + Name *string `json:"name,omitempty"` + Volumes *[]VolumeDefinition `json:"volumes,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_databricks.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_databricks.go new file mode 100644 index 00000000000..39d8cae90ae --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_databricks.go @@ -0,0 +1,95 @@ +package operationalizationclusters + +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. + +var _ Compute = Databricks{} + +type Databricks struct { + Properties *DatabricksProperties `json:"properties,omitempty"` + + // Fields inherited from Compute + + ComputeLocation *string `json:"computeLocation,omitempty"` + ComputeType ComputeType `json:"computeType"` + CreatedOn *string `json:"createdOn,omitempty"` + Description *string `json:"description,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + IsAttachedCompute *bool `json:"isAttachedCompute,omitempty"` + ModifiedOn *string `json:"modifiedOn,omitempty"` + ProvisioningErrors *[]ErrorResponse `json:"provisioningErrors,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} + +func (s Databricks) Compute() BaseComputeImpl { + return BaseComputeImpl{ + ComputeLocation: s.ComputeLocation, + ComputeType: s.ComputeType, + CreatedOn: s.CreatedOn, + Description: s.Description, + DisableLocalAuth: s.DisableLocalAuth, + IsAttachedCompute: s.IsAttachedCompute, + ModifiedOn: s.ModifiedOn, + ProvisioningErrors: s.ProvisioningErrors, + ProvisioningState: s.ProvisioningState, + ResourceId: s.ResourceId, + } +} + +func (o *Databricks) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *Databricks) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} + +func (o *Databricks) GetModifiedOnAsTime() (*time.Time, error) { + if o.ModifiedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *Databricks) SetModifiedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedOn = &formatted +} + +var _ json.Marshaler = Databricks{} + +func (s Databricks) MarshalJSON() ([]byte, error) { + type wrapper Databricks + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling Databricks: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling Databricks: %+v", err) + } + + decoded["computeType"] = "Databricks" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling Databricks: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_databrickscomputesecrets.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_databrickscomputesecrets.go new file mode 100644 index 00000000000..94994c59bfc --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_databrickscomputesecrets.go @@ -0,0 +1,50 @@ +package operationalizationclusters + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ComputeSecrets = DatabricksComputeSecrets{} + +type DatabricksComputeSecrets struct { + DatabricksAccessToken *string `json:"databricksAccessToken,omitempty"` + + // Fields inherited from ComputeSecrets + + ComputeType ComputeType `json:"computeType"` +} + +func (s DatabricksComputeSecrets) ComputeSecrets() BaseComputeSecretsImpl { + return BaseComputeSecretsImpl{ + ComputeType: s.ComputeType, + } +} + +var _ json.Marshaler = DatabricksComputeSecrets{} + +func (s DatabricksComputeSecrets) MarshalJSON() ([]byte, error) { + type wrapper DatabricksComputeSecrets + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DatabricksComputeSecrets: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DatabricksComputeSecrets: %+v", err) + } + + decoded["computeType"] = "Databricks" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DatabricksComputeSecrets: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_databricksproperties.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_databricksproperties.go new file mode 100644 index 00000000000..ebb94d4ce85 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_databricksproperties.go @@ -0,0 +1,9 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DatabricksProperties struct { + DatabricksAccessToken *string `json:"databricksAccessToken,omitempty"` + WorkspaceURL *string `json:"workspaceUrl,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_datafactory.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_datafactory.go new file mode 100644 index 00000000000..def0dd5a5f4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_datafactory.go @@ -0,0 +1,94 @@ +package operationalizationclusters + +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. + +var _ Compute = DataFactory{} + +type DataFactory struct { + + // Fields inherited from Compute + + ComputeLocation *string `json:"computeLocation,omitempty"` + ComputeType ComputeType `json:"computeType"` + CreatedOn *string `json:"createdOn,omitempty"` + Description *string `json:"description,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + IsAttachedCompute *bool `json:"isAttachedCompute,omitempty"` + ModifiedOn *string `json:"modifiedOn,omitempty"` + ProvisioningErrors *[]ErrorResponse `json:"provisioningErrors,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} + +func (s DataFactory) Compute() BaseComputeImpl { + return BaseComputeImpl{ + ComputeLocation: s.ComputeLocation, + ComputeType: s.ComputeType, + CreatedOn: s.CreatedOn, + Description: s.Description, + DisableLocalAuth: s.DisableLocalAuth, + IsAttachedCompute: s.IsAttachedCompute, + ModifiedOn: s.ModifiedOn, + ProvisioningErrors: s.ProvisioningErrors, + ProvisioningState: s.ProvisioningState, + ResourceId: s.ResourceId, + } +} + +func (o *DataFactory) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *DataFactory) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} + +func (o *DataFactory) GetModifiedOnAsTime() (*time.Time, error) { + if o.ModifiedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *DataFactory) SetModifiedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedOn = &formatted +} + +var _ json.Marshaler = DataFactory{} + +func (s DataFactory) MarshalJSON() ([]byte, error) { + type wrapper DataFactory + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DataFactory: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DataFactory: %+v", err) + } + + decoded["computeType"] = "DataFactory" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DataFactory: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_datalakeanalytics.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_datalakeanalytics.go new file mode 100644 index 00000000000..816904cf145 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_datalakeanalytics.go @@ -0,0 +1,95 @@ +package operationalizationclusters + +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. + +var _ Compute = DataLakeAnalytics{} + +type DataLakeAnalytics struct { + Properties *DataLakeAnalyticsSchemaProperties `json:"properties,omitempty"` + + // Fields inherited from Compute + + ComputeLocation *string `json:"computeLocation,omitempty"` + ComputeType ComputeType `json:"computeType"` + CreatedOn *string `json:"createdOn,omitempty"` + Description *string `json:"description,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + IsAttachedCompute *bool `json:"isAttachedCompute,omitempty"` + ModifiedOn *string `json:"modifiedOn,omitempty"` + ProvisioningErrors *[]ErrorResponse `json:"provisioningErrors,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} + +func (s DataLakeAnalytics) Compute() BaseComputeImpl { + return BaseComputeImpl{ + ComputeLocation: s.ComputeLocation, + ComputeType: s.ComputeType, + CreatedOn: s.CreatedOn, + Description: s.Description, + DisableLocalAuth: s.DisableLocalAuth, + IsAttachedCompute: s.IsAttachedCompute, + ModifiedOn: s.ModifiedOn, + ProvisioningErrors: s.ProvisioningErrors, + ProvisioningState: s.ProvisioningState, + ResourceId: s.ResourceId, + } +} + +func (o *DataLakeAnalytics) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *DataLakeAnalytics) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} + +func (o *DataLakeAnalytics) GetModifiedOnAsTime() (*time.Time, error) { + if o.ModifiedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *DataLakeAnalytics) SetModifiedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedOn = &formatted +} + +var _ json.Marshaler = DataLakeAnalytics{} + +func (s DataLakeAnalytics) MarshalJSON() ([]byte, error) { + type wrapper DataLakeAnalytics + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DataLakeAnalytics: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DataLakeAnalytics: %+v", err) + } + + decoded["computeType"] = "DataLakeAnalytics" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DataLakeAnalytics: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_datalakeanalyticsschemaproperties.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_datalakeanalyticsschemaproperties.go new file mode 100644 index 00000000000..992dd395bd9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_datalakeanalyticsschemaproperties.go @@ -0,0 +1,8 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DataLakeAnalyticsSchemaProperties struct { + DataLakeStoreAccountName *string `json:"dataLakeStoreAccountName,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_docker.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_docker.go new file mode 100644 index 00000000000..67267285f4f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_docker.go @@ -0,0 +1,8 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Docker struct { + Privileged *bool `json:"privileged,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_endpoint.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_endpoint.go new file mode 100644 index 00000000000..222da6b2a8e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_endpoint.go @@ -0,0 +1,12 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Endpoint struct { + HostIP *string `json:"hostIp,omitempty"` + Name *string `json:"name,omitempty"` + Protocol *Protocol `json:"protocol,omitempty"` + Published *int64 `json:"published,omitempty"` + Target *int64 `json:"target,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_environmentvariable.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_environmentvariable.go new file mode 100644 index 00000000000..7502ef9b24c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_environmentvariable.go @@ -0,0 +1,9 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EnvironmentVariable struct { + Type *EnvironmentVariableType `json:"type,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_erroradditionalinfo.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_erroradditionalinfo.go new file mode 100644 index 00000000000..a6594d4ddbf --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_erroradditionalinfo.go @@ -0,0 +1,9 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorAdditionalInfo struct { + Info *interface{} `json:"info,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_errordetail.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_errordetail.go new file mode 100644 index 00000000000..c46fbde33ba --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_errordetail.go @@ -0,0 +1,12 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorDetail struct { + AdditionalInfo *[]ErrorAdditionalInfo `json:"additionalInfo,omitempty"` + Code *string `json:"code,omitempty"` + Details *[]ErrorDetail `json:"details,omitempty"` + Message *string `json:"message,omitempty"` + Target *string `json:"target,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_errorresponse.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_errorresponse.go new file mode 100644 index 00000000000..0cf8646165e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_errorresponse.go @@ -0,0 +1,8 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ErrorResponse struct { + Error *ErrorDetail `json:"error,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_hdinsight.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_hdinsight.go new file mode 100644 index 00000000000..28c33c4be11 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_hdinsight.go @@ -0,0 +1,95 @@ +package operationalizationclusters + +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. + +var _ Compute = HDInsight{} + +type HDInsight struct { + Properties *HDInsightProperties `json:"properties,omitempty"` + + // Fields inherited from Compute + + ComputeLocation *string `json:"computeLocation,omitempty"` + ComputeType ComputeType `json:"computeType"` + CreatedOn *string `json:"createdOn,omitempty"` + Description *string `json:"description,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + IsAttachedCompute *bool `json:"isAttachedCompute,omitempty"` + ModifiedOn *string `json:"modifiedOn,omitempty"` + ProvisioningErrors *[]ErrorResponse `json:"provisioningErrors,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} + +func (s HDInsight) Compute() BaseComputeImpl { + return BaseComputeImpl{ + ComputeLocation: s.ComputeLocation, + ComputeType: s.ComputeType, + CreatedOn: s.CreatedOn, + Description: s.Description, + DisableLocalAuth: s.DisableLocalAuth, + IsAttachedCompute: s.IsAttachedCompute, + ModifiedOn: s.ModifiedOn, + ProvisioningErrors: s.ProvisioningErrors, + ProvisioningState: s.ProvisioningState, + ResourceId: s.ResourceId, + } +} + +func (o *HDInsight) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *HDInsight) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} + +func (o *HDInsight) GetModifiedOnAsTime() (*time.Time, error) { + if o.ModifiedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *HDInsight) SetModifiedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedOn = &formatted +} + +var _ json.Marshaler = HDInsight{} + +func (s HDInsight) MarshalJSON() ([]byte, error) { + type wrapper HDInsight + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling HDInsight: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling HDInsight: %+v", err) + } + + decoded["computeType"] = "HDInsight" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling HDInsight: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_hdinsightproperties.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_hdinsightproperties.go new file mode 100644 index 00000000000..3d21f3136a1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_hdinsightproperties.go @@ -0,0 +1,10 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type HDInsightProperties struct { + Address *string `json:"address,omitempty"` + AdministratorAccount *VirtualMachineSshCredentials `json:"administratorAccount,omitempty"` + SshPort *int64 `json:"sshPort,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_image.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_image.go new file mode 100644 index 00000000000..edaf215d6d9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_image.go @@ -0,0 +1,9 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Image struct { + Reference *string `json:"reference,omitempty"` + Type *ImageType `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_imagemetadata.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_imagemetadata.go new file mode 100644 index 00000000000..2649f521be4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_imagemetadata.go @@ -0,0 +1,10 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImageMetadata struct { + CurrentImageVersion *string `json:"currentImageVersion,omitempty"` + IsLatestOsImageVersion *bool `json:"isLatestOsImageVersion,omitempty"` + LatestImageVersion *string `json:"latestImageVersion,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_instancetypeschema.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_instancetypeschema.go new file mode 100644 index 00000000000..dcece7c3adf --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_instancetypeschema.go @@ -0,0 +1,9 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InstanceTypeSchema struct { + NodeSelector *map[string]string `json:"nodeSelector,omitempty"` + Resources *InstanceTypeSchemaResources `json:"resources,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_instancetypeschemaresources.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_instancetypeschemaresources.go new file mode 100644 index 00000000000..ce51c40535a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_instancetypeschemaresources.go @@ -0,0 +1,9 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type InstanceTypeSchemaResources struct { + Limits *map[string]string `json:"limits,omitempty"` + Requests *map[string]string `json:"requests,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_kubernetes.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_kubernetes.go new file mode 100644 index 00000000000..8cabecbafdb --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_kubernetes.go @@ -0,0 +1,95 @@ +package operationalizationclusters + +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. + +var _ Compute = Kubernetes{} + +type Kubernetes struct { + Properties *KubernetesProperties `json:"properties,omitempty"` + + // Fields inherited from Compute + + ComputeLocation *string `json:"computeLocation,omitempty"` + ComputeType ComputeType `json:"computeType"` + CreatedOn *string `json:"createdOn,omitempty"` + Description *string `json:"description,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + IsAttachedCompute *bool `json:"isAttachedCompute,omitempty"` + ModifiedOn *string `json:"modifiedOn,omitempty"` + ProvisioningErrors *[]ErrorResponse `json:"provisioningErrors,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} + +func (s Kubernetes) Compute() BaseComputeImpl { + return BaseComputeImpl{ + ComputeLocation: s.ComputeLocation, + ComputeType: s.ComputeType, + CreatedOn: s.CreatedOn, + Description: s.Description, + DisableLocalAuth: s.DisableLocalAuth, + IsAttachedCompute: s.IsAttachedCompute, + ModifiedOn: s.ModifiedOn, + ProvisioningErrors: s.ProvisioningErrors, + ProvisioningState: s.ProvisioningState, + ResourceId: s.ResourceId, + } +} + +func (o *Kubernetes) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *Kubernetes) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} + +func (o *Kubernetes) GetModifiedOnAsTime() (*time.Time, error) { + if o.ModifiedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *Kubernetes) SetModifiedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedOn = &formatted +} + +var _ json.Marshaler = Kubernetes{} + +func (s Kubernetes) MarshalJSON() ([]byte, error) { + type wrapper Kubernetes + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling Kubernetes: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling Kubernetes: %+v", err) + } + + decoded["computeType"] = "Kubernetes" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling Kubernetes: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_kubernetesproperties.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_kubernetesproperties.go new file mode 100644 index 00000000000..ccc8225f273 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_kubernetesproperties.go @@ -0,0 +1,15 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type KubernetesProperties struct { + DefaultInstanceType *string `json:"defaultInstanceType,omitempty"` + ExtensionInstanceReleaseTrain *string `json:"extensionInstanceReleaseTrain,omitempty"` + ExtensionPrincipalId *string `json:"extensionPrincipalId,omitempty"` + InstanceTypes *map[string]InstanceTypeSchema `json:"instanceTypes,omitempty"` + Namespace *string `json:"namespace,omitempty"` + RelayConnectionString *string `json:"relayConnectionString,omitempty"` + ServiceBusConnectionString *string `json:"serviceBusConnectionString,omitempty"` + VcName *string `json:"vcName,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_nodestatecounts.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_nodestatecounts.go new file mode 100644 index 00000000000..4baa87819fb --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_nodestatecounts.go @@ -0,0 +1,13 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NodeStateCounts struct { + IdleNodeCount *int64 `json:"idleNodeCount,omitempty"` + LeavingNodeCount *int64 `json:"leavingNodeCount,omitempty"` + PreemptedNodeCount *int64 `json:"preemptedNodeCount,omitempty"` + PreparingNodeCount *int64 `json:"preparingNodeCount,omitempty"` + RunningNodeCount *int64 `json:"runningNodeCount,omitempty"` + UnusableNodeCount *int64 `json:"unusableNodeCount,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_personalcomputeinstancesettings.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_personalcomputeinstancesettings.go new file mode 100644 index 00000000000..04f1adc0a0a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_personalcomputeinstancesettings.go @@ -0,0 +1,8 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PersonalComputeInstanceSettings struct { + AssignedUser *AssignedUser `json:"assignedUser,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_recurrence.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_recurrence.go new file mode 100644 index 00000000000..11e354deea5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_recurrence.go @@ -0,0 +1,12 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Recurrence struct { + Frequency *ComputeRecurrenceFrequency `json:"frequency,omitempty"` + Interval *int64 `json:"interval,omitempty"` + Schedule *ComputeRecurrenceSchedule `json:"schedule,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_resourceid.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_resourceid.go new file mode 100644 index 00000000000..5b09e66c6a8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_resourceid.go @@ -0,0 +1,8 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceId struct { + Id string `json:"id"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_scalesettings.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_scalesettings.go new file mode 100644 index 00000000000..85d0a9919a1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_scalesettings.go @@ -0,0 +1,10 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScaleSettings struct { + MaxNodeCount int64 `json:"maxNodeCount"` + MinNodeCount *int64 `json:"minNodeCount,omitempty"` + NodeIdleTimeBeforeScaleDown *string `json:"nodeIdleTimeBeforeScaleDown,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_scalesettingsinformation.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_scalesettingsinformation.go new file mode 100644 index 00000000000..a54c38e8427 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_scalesettingsinformation.go @@ -0,0 +1,8 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScaleSettingsInformation struct { + ScaleSettings *ScaleSettings `json:"scaleSettings,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_schedulebase.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_schedulebase.go new file mode 100644 index 00000000000..2d7b09d54e8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_schedulebase.go @@ -0,0 +1,10 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScheduleBase struct { + Id *string `json:"id,omitempty"` + ProvisioningStatus *ScheduleProvisioningState `json:"provisioningStatus,omitempty"` + Status *ScheduleStatus `json:"status,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_scriptreference.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_scriptreference.go new file mode 100644 index 00000000000..2591c52965e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_scriptreference.go @@ -0,0 +1,11 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScriptReference struct { + ScriptArguments *string `json:"scriptArguments,omitempty"` + ScriptData *string `json:"scriptData,omitempty"` + ScriptSource *string `json:"scriptSource,omitempty"` + Timeout *string `json:"timeout,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_scriptstoexecute.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_scriptstoexecute.go new file mode 100644 index 00000000000..833be6e884b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_scriptstoexecute.go @@ -0,0 +1,9 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScriptsToExecute struct { + CreationScript *ScriptReference `json:"creationScript,omitempty"` + StartupScript *ScriptReference `json:"startupScript,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_setupscripts.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_setupscripts.go new file mode 100644 index 00000000000..121c9f13ee8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_setupscripts.go @@ -0,0 +1,8 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SetupScripts struct { + Scripts *ScriptsToExecute `json:"scripts,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_sku.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_sku.go new file mode 100644 index 00000000000..cfedc2c9e35 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_sku.go @@ -0,0 +1,12 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Name string `json:"name"` + Size *string `json:"size,omitempty"` + Tier *SkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_sslconfiguration.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_sslconfiguration.go new file mode 100644 index 00000000000..fd3cc26751c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_sslconfiguration.go @@ -0,0 +1,13 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SslConfiguration struct { + Cert *string `json:"cert,omitempty"` + Cname *string `json:"cname,omitempty"` + Key *string `json:"key,omitempty"` + LeafDomainLabel *string `json:"leafDomainLabel,omitempty"` + OverwriteExistingDomain *bool `json:"overwriteExistingDomain,omitempty"` + Status *SslConfigStatus `json:"status,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_synapsespark.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_synapsespark.go new file mode 100644 index 00000000000..e48bdb81c9e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_synapsespark.go @@ -0,0 +1,95 @@ +package operationalizationclusters + +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. + +var _ Compute = SynapseSpark{} + +type SynapseSpark struct { + Properties *SynapseSparkProperties `json:"properties,omitempty"` + + // Fields inherited from Compute + + ComputeLocation *string `json:"computeLocation,omitempty"` + ComputeType ComputeType `json:"computeType"` + CreatedOn *string `json:"createdOn,omitempty"` + Description *string `json:"description,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + IsAttachedCompute *bool `json:"isAttachedCompute,omitempty"` + ModifiedOn *string `json:"modifiedOn,omitempty"` + ProvisioningErrors *[]ErrorResponse `json:"provisioningErrors,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} + +func (s SynapseSpark) Compute() BaseComputeImpl { + return BaseComputeImpl{ + ComputeLocation: s.ComputeLocation, + ComputeType: s.ComputeType, + CreatedOn: s.CreatedOn, + Description: s.Description, + DisableLocalAuth: s.DisableLocalAuth, + IsAttachedCompute: s.IsAttachedCompute, + ModifiedOn: s.ModifiedOn, + ProvisioningErrors: s.ProvisioningErrors, + ProvisioningState: s.ProvisioningState, + ResourceId: s.ResourceId, + } +} + +func (o *SynapseSpark) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *SynapseSpark) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} + +func (o *SynapseSpark) GetModifiedOnAsTime() (*time.Time, error) { + if o.ModifiedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *SynapseSpark) SetModifiedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedOn = &formatted +} + +var _ json.Marshaler = SynapseSpark{} + +func (s SynapseSpark) MarshalJSON() ([]byte, error) { + type wrapper SynapseSpark + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SynapseSpark: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SynapseSpark: %+v", err) + } + + decoded["computeType"] = "SynapseSpark" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SynapseSpark: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_synapsesparkproperties.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_synapsesparkproperties.go new file mode 100644 index 00000000000..eec051e8883 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_synapsesparkproperties.go @@ -0,0 +1,17 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SynapseSparkProperties struct { + AutoPauseProperties *AutoPauseProperties `json:"autoPauseProperties,omitempty"` + AutoScaleProperties *AutoScaleProperties `json:"autoScaleProperties,omitempty"` + NodeCount *int64 `json:"nodeCount,omitempty"` + NodeSize *string `json:"nodeSize,omitempty"` + NodeSizeFamily *string `json:"nodeSizeFamily,omitempty"` + PoolName *string `json:"poolName,omitempty"` + ResourceGroup *string `json:"resourceGroup,omitempty"` + SparkVersion *string `json:"sparkVersion,omitempty"` + SubscriptionId *string `json:"subscriptionId,omitempty"` + WorkspaceName *string `json:"workspaceName,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_systemservice.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_systemservice.go new file mode 100644 index 00000000000..b0cd27722cf --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_systemservice.go @@ -0,0 +1,10 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SystemService struct { + PublicIPAddress *string `json:"publicIpAddress,omitempty"` + SystemServiceType *string `json:"systemServiceType,omitempty"` + Version *string `json:"version,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_tmpfsoptions.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_tmpfsoptions.go new file mode 100644 index 00000000000..452bec44e9e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_tmpfsoptions.go @@ -0,0 +1,8 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TmpfsOptions struct { + Size *int64 `json:"size,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_useraccountcredentials.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_useraccountcredentials.go new file mode 100644 index 00000000000..e343e28dad9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_useraccountcredentials.go @@ -0,0 +1,10 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UserAccountCredentials struct { + AdminUserName string `json:"adminUserName"` + AdminUserPassword *string `json:"adminUserPassword,omitempty"` + AdminUserSshPublicKey *string `json:"adminUserSshPublicKey,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_virtualmachine.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_virtualmachine.go new file mode 100644 index 00000000000..22c21beff85 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_virtualmachine.go @@ -0,0 +1,95 @@ +package operationalizationclusters + +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. + +var _ Compute = VirtualMachine{} + +type VirtualMachine struct { + Properties *VirtualMachineSchemaProperties `json:"properties,omitempty"` + + // Fields inherited from Compute + + ComputeLocation *string `json:"computeLocation,omitempty"` + ComputeType ComputeType `json:"computeType"` + CreatedOn *string `json:"createdOn,omitempty"` + Description *string `json:"description,omitempty"` + DisableLocalAuth *bool `json:"disableLocalAuth,omitempty"` + IsAttachedCompute *bool `json:"isAttachedCompute,omitempty"` + ModifiedOn *string `json:"modifiedOn,omitempty"` + ProvisioningErrors *[]ErrorResponse `json:"provisioningErrors,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} + +func (s VirtualMachine) Compute() BaseComputeImpl { + return BaseComputeImpl{ + ComputeLocation: s.ComputeLocation, + ComputeType: s.ComputeType, + CreatedOn: s.CreatedOn, + Description: s.Description, + DisableLocalAuth: s.DisableLocalAuth, + IsAttachedCompute: s.IsAttachedCompute, + ModifiedOn: s.ModifiedOn, + ProvisioningErrors: s.ProvisioningErrors, + ProvisioningState: s.ProvisioningState, + ResourceId: s.ResourceId, + } +} + +func (o *VirtualMachine) GetCreatedOnAsTime() (*time.Time, error) { + if o.CreatedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.CreatedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *VirtualMachine) SetCreatedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.CreatedOn = &formatted +} + +func (o *VirtualMachine) GetModifiedOnAsTime() (*time.Time, error) { + if o.ModifiedOn == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ModifiedOn, "2006-01-02T15:04:05Z07:00") +} + +func (o *VirtualMachine) SetModifiedOnAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ModifiedOn = &formatted +} + +var _ json.Marshaler = VirtualMachine{} + +func (s VirtualMachine) MarshalJSON() ([]byte, error) { + type wrapper VirtualMachine + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VirtualMachine: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VirtualMachine: %+v", err) + } + + decoded["computeType"] = "VirtualMachine" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VirtualMachine: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_virtualmachineimage.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_virtualmachineimage.go new file mode 100644 index 00000000000..caae2fa3c7d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_virtualmachineimage.go @@ -0,0 +1,8 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineImage struct { + Id string `json:"id"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_virtualmachineschemaproperties.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_virtualmachineschemaproperties.go new file mode 100644 index 00000000000..a3150d40e57 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_virtualmachineschemaproperties.go @@ -0,0 +1,13 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineSchemaProperties struct { + Address *string `json:"address,omitempty"` + AdministratorAccount *VirtualMachineSshCredentials `json:"administratorAccount,omitempty"` + IsNotebookInstanceCompute *bool `json:"isNotebookInstanceCompute,omitempty"` + NotebookServerPort *int64 `json:"notebookServerPort,omitempty"` + SshPort *int64 `json:"sshPort,omitempty"` + VirtualMachineSize *string `json:"virtualMachineSize,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_virtualmachinesecrets.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_virtualmachinesecrets.go new file mode 100644 index 00000000000..c575b8e5d07 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_virtualmachinesecrets.go @@ -0,0 +1,50 @@ +package operationalizationclusters + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ComputeSecrets = VirtualMachineSecrets{} + +type VirtualMachineSecrets struct { + AdministratorAccount *VirtualMachineSshCredentials `json:"administratorAccount,omitempty"` + + // Fields inherited from ComputeSecrets + + ComputeType ComputeType `json:"computeType"` +} + +func (s VirtualMachineSecrets) ComputeSecrets() BaseComputeSecretsImpl { + return BaseComputeSecretsImpl{ + ComputeType: s.ComputeType, + } +} + +var _ json.Marshaler = VirtualMachineSecrets{} + +func (s VirtualMachineSecrets) MarshalJSON() ([]byte, error) { + type wrapper VirtualMachineSecrets + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling VirtualMachineSecrets: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling VirtualMachineSecrets: %+v", err) + } + + decoded["computeType"] = "VirtualMachine" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling VirtualMachineSecrets: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_virtualmachinesshcredentials.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_virtualmachinesshcredentials.go new file mode 100644 index 00000000000..dc08a5c5c6b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_virtualmachinesshcredentials.go @@ -0,0 +1,11 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineSshCredentials struct { + Password *string `json:"password,omitempty"` + PrivateKeyData *string `json:"privateKeyData,omitempty"` + PublicKeyData *string `json:"publicKeyData,omitempty"` + Username *string `json:"username,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_volumedefinition.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_volumedefinition.go new file mode 100644 index 00000000000..1a5ec6aa7a9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_volumedefinition.go @@ -0,0 +1,15 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeDefinition struct { + Bind *BindOptions `json:"bind,omitempty"` + Consistency *string `json:"consistency,omitempty"` + ReadOnly *bool `json:"readOnly,omitempty"` + Source *string `json:"source,omitempty"` + Target *string `json:"target,omitempty"` + Tmpfs *TmpfsOptions `json:"tmpfs,omitempty"` + Type *VolumeDefinitionType `json:"type,omitempty"` + Volume *VolumeOptions `json:"volume,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_volumeoptions.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_volumeoptions.go new file mode 100644 index 00000000000..78a1ec9669f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/model_volumeoptions.go @@ -0,0 +1,8 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VolumeOptions struct { + Nocopy *bool `json:"nocopy,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/predicates.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/predicates.go new file mode 100644 index 00000000000..cd66eac32cf --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/predicates.go @@ -0,0 +1,32 @@ +package operationalizationclusters + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeResourceOperationPredicate struct { + Id *string + Location *string + Name *string + Type *string +} + +func (p ComputeResourceOperationPredicate) Matches(input ComputeResource) 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/machinelearningservices/2025-04-01/operationalizationclusters/version.go b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/version.go new file mode 100644 index 00000000000..ebb844749cf --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/operationalizationclusters/version.go @@ -0,0 +1,10 @@ +package operationalizationclusters + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/operationalizationclusters/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/README.md b/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/README.md new file mode 100644 index 00000000000..2eb74000036 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints` Documentation + +The `outboundnetworkdependenciesendpoints` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints" +``` + + +### Client Initialization + +```go +client := outboundnetworkdependenciesendpoints.NewOutboundNetworkDependenciesEndpointsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `OutboundNetworkDependenciesEndpointsClient.WorkspacesListOutboundNetworkDependenciesEndpoints` + +```go +ctx := context.TODO() +id := outboundnetworkdependenciesendpoints.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.WorkspacesListOutboundNetworkDependenciesEndpoints(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/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/client.go b/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/client.go new file mode 100644 index 00000000000..a8a36d8265e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/client.go @@ -0,0 +1,26 @@ +package outboundnetworkdependenciesendpoints + +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 OutboundNetworkDependenciesEndpointsClient struct { + Client *resourcemanager.Client +} + +func NewOutboundNetworkDependenciesEndpointsClientWithBaseURI(sdkApi sdkEnv.Api) (*OutboundNetworkDependenciesEndpointsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "outboundnetworkdependenciesendpoints", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating OutboundNetworkDependenciesEndpointsClient: %+v", err) + } + + return &OutboundNetworkDependenciesEndpointsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/id_workspace.go b/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/id_workspace.go new file mode 100644 index 00000000000..f083d55d3dd --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/id_workspace.go @@ -0,0 +1,130 @@ +package outboundnetworkdependenciesendpoints + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/id_workspace_test.go b/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/id_workspace_test.go new file mode 100644 index 00000000000..e677cce9975 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/id_workspace_test.go @@ -0,0 +1,282 @@ +package outboundnetworkdependenciesendpoints + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/method_workspaceslistoutboundnetworkdependenciesendpoints.go b/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/method_workspaceslistoutboundnetworkdependenciesendpoints.go new file mode 100644 index 00000000000..36b14ed1653 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/method_workspaceslistoutboundnetworkdependenciesendpoints.go @@ -0,0 +1,54 @@ +package outboundnetworkdependenciesendpoints + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspacesListOutboundNetworkDependenciesEndpointsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ExternalFQDNResponse +} + +// WorkspacesListOutboundNetworkDependenciesEndpoints ... +func (c OutboundNetworkDependenciesEndpointsClient) WorkspacesListOutboundNetworkDependenciesEndpoints(ctx context.Context, id WorkspaceId) (result WorkspacesListOutboundNetworkDependenciesEndpointsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + 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.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ExternalFQDNResponse + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/model_externalfqdnresponse.go b/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/model_externalfqdnresponse.go new file mode 100644 index 00000000000..d56433d7e49 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/model_externalfqdnresponse.go @@ -0,0 +1,8 @@ +package outboundnetworkdependenciesendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ExternalFQDNResponse struct { + Value *[]FQDNEndpoints `json:"value,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/model_fqdnendpoint.go b/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/model_fqdnendpoint.go new file mode 100644 index 00000000000..e81cf44272b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/model_fqdnendpoint.go @@ -0,0 +1,9 @@ +package outboundnetworkdependenciesendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FQDNEndpoint struct { + DomainName *string `json:"domainName,omitempty"` + EndpointDetails *[]FQDNEndpointDetail `json:"endpointDetails,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/model_fqdnendpointdetail.go b/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/model_fqdnendpointdetail.go new file mode 100644 index 00000000000..18e1e57dbb8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/model_fqdnendpointdetail.go @@ -0,0 +1,8 @@ +package outboundnetworkdependenciesendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FQDNEndpointDetail struct { + Port *int64 `json:"port,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/model_fqdnendpoints.go b/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/model_fqdnendpoints.go new file mode 100644 index 00000000000..e4ddc83f810 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/model_fqdnendpoints.go @@ -0,0 +1,8 @@ +package outboundnetworkdependenciesendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FQDNEndpoints struct { + Properties *FQDNEndpointsProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/model_fqdnendpointsproperties.go b/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/model_fqdnendpointsproperties.go new file mode 100644 index 00000000000..1499a609b7d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/model_fqdnendpointsproperties.go @@ -0,0 +1,9 @@ +package outboundnetworkdependenciesendpoints + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FQDNEndpointsProperties struct { + Category *string `json:"category,omitempty"` + Endpoints *[]FQDNEndpoint `json:"endpoints,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/version.go b/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/version.go new file mode 100644 index 00000000000..ee74161cdbf --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/outboundnetworkdependenciesendpoints/version.go @@ -0,0 +1,10 @@ +package outboundnetworkdependenciesendpoints + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/outboundnetworkdependenciesendpoints/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/README.md b/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/README.md new file mode 100644 index 00000000000..57e4dc3efce --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections` Documentation + +The `privateendpointconnections` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections" +``` + + +### Client Initialization + +```go +client := privateendpointconnections.NewPrivateEndpointConnectionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `PrivateEndpointConnectionsClient.List` + +```go +ctx := context.TODO() +id := privateendpointconnections.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.List(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/client.go b/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/client.go new file mode 100644 index 00000000000..50eaf09dcce --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-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/machinelearningservices/2025-04-01/privateendpointconnections/constants.go b/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/constants.go new file mode 100644 index 00000000000..f630c4a87c4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/constants.go @@ -0,0 +1,154 @@ +package privateendpointconnections + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + } +} + +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusDisconnected PrivateEndpointServiceConnectionStatus = "Disconnected" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" + PrivateEndpointServiceConnectionStatusTimeout PrivateEndpointServiceConnectionStatus = "Timeout" +) + +func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { + return []string{ + string(PrivateEndpointServiceConnectionStatusApproved), + string(PrivateEndpointServiceConnectionStatusDisconnected), + string(PrivateEndpointServiceConnectionStatusPending), + string(PrivateEndpointServiceConnectionStatusRejected), + string(PrivateEndpointServiceConnectionStatusTimeout), + } +} + +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { + vals := map[string]PrivateEndpointServiceConnectionStatus{ + "approved": PrivateEndpointServiceConnectionStatusApproved, + "disconnected": PrivateEndpointServiceConnectionStatusDisconnected, + "pending": PrivateEndpointServiceConnectionStatusPending, + "rejected": PrivateEndpointServiceConnectionStatusRejected, + "timeout": PrivateEndpointServiceConnectionStatusTimeout, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointServiceConnectionStatus(input) + return &out, nil +} + +type SkuTier string + +const ( + SkuTierBasic SkuTier = "Basic" + SkuTierFree SkuTier = "Free" + SkuTierPremium SkuTier = "Premium" + SkuTierStandard SkuTier = "Standard" +) + +func PossibleValuesForSkuTier() []string { + return []string{ + string(SkuTierBasic), + string(SkuTierFree), + string(SkuTierPremium), + string(SkuTierStandard), + } +} + +func (s *SkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuTier(input string) (*SkuTier, error) { + vals := map[string]SkuTier{ + "basic": SkuTierBasic, + "free": SkuTierFree, + "premium": SkuTierPremium, + "standard": SkuTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuTier(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/id_workspace.go b/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/id_workspace.go new file mode 100644 index 00000000000..e31c596b09a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/id_workspace.go @@ -0,0 +1,130 @@ +package privateendpointconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/id_workspace_test.go b/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/id_workspace_test.go new file mode 100644 index 00000000000..78f31e3df60 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/id_workspace_test.go @@ -0,0 +1,282 @@ +package privateendpointconnections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/method_list.go b/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/method_list.go new file mode 100644 index 00000000000..7b076e7cbda --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/method_list.go @@ -0,0 +1,54 @@ +package privateendpointconnections + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnectionListResult +} + +// List ... +func (c PrivateEndpointConnectionsClient) List(ctx context.Context, id WorkspaceId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/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/machinelearningservices/2025-04-01/privateendpointconnections/model_privateendpoint.go b/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/model_privateendpoint.go new file mode 100644 index 00000000000..1bc8cf2a97c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-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/machinelearningservices/2025-04-01/privateendpointconnections/model_privateendpointconnection.go b/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/model_privateendpointconnection.go new file mode 100644 index 00000000000..994556d3600 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/model_privateendpointconnection.go @@ -0,0 +1,21 @@ +package privateendpointconnections + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/model_privateendpointconnectionlistresult.go b/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/model_privateendpointconnectionlistresult.go new file mode 100644 index 00000000000..92a9ecb105a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-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/machinelearningservices/2025-04-01/privateendpointconnections/model_privateendpointconnectionproperties.go b/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..549d255f069 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-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/machinelearningservices/2025-04-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go b/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..ec3f7a9f24c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package privateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/model_sku.go b/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/model_sku.go new file mode 100644 index 00000000000..7adf69929a1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/model_sku.go @@ -0,0 +1,12 @@ +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 Sku struct { + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Name string `json:"name"` + Size *string `json:"size,omitempty"` + Tier *SkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/version.go b/resource-manager/machinelearningservices/2025-04-01/privateendpointconnections/version.go new file mode 100644 index 00000000000..4975b737870 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/privateendpointconnections/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/proxyoperations/README.md b/resource-manager/machinelearningservices/2025-04-01/proxyoperations/README.md new file mode 100644 index 00000000000..55de0ab091e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/proxyoperations/README.md @@ -0,0 +1,64 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/proxyoperations` Documentation + +The `proxyoperations` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/proxyoperations" +``` + + +### Client Initialization + +```go +client := proxyoperations.NewProxyOperationsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ProxyOperationsClient.WorkspacesListNotebookKeys` + +```go +ctx := context.TODO() +id := proxyoperations.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.WorkspacesListNotebookKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProxyOperationsClient.WorkspacesListStorageAccountKeys` + +```go +ctx := context.TODO() +id := proxyoperations.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.WorkspacesListStorageAccountKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ProxyOperationsClient.WorkspacesPrepareNotebook` + +```go +ctx := context.TODO() +id := proxyoperations.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +if err := client.WorkspacesPrepareNotebookThenPoll(ctx, id); err != nil { + // handle the error +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/proxyoperations/client.go b/resource-manager/machinelearningservices/2025-04-01/proxyoperations/client.go new file mode 100644 index 00000000000..18542e7d1e7 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/proxyoperations/client.go @@ -0,0 +1,26 @@ +package proxyoperations + +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 ProxyOperationsClient struct { + Client *resourcemanager.Client +} + +func NewProxyOperationsClientWithBaseURI(sdkApi sdkEnv.Api) (*ProxyOperationsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "proxyoperations", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ProxyOperationsClient: %+v", err) + } + + return &ProxyOperationsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/proxyoperations/id_workspace.go b/resource-manager/machinelearningservices/2025-04-01/proxyoperations/id_workspace.go new file mode 100644 index 00000000000..67249c5c909 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/proxyoperations/id_workspace.go @@ -0,0 +1,130 @@ +package proxyoperations + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/proxyoperations/id_workspace_test.go b/resource-manager/machinelearningservices/2025-04-01/proxyoperations/id_workspace_test.go new file mode 100644 index 00000000000..23404aa1790 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/proxyoperations/id_workspace_test.go @@ -0,0 +1,282 @@ +package proxyoperations + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/proxyoperations/method_workspaceslistnotebookkeys.go b/resource-manager/machinelearningservices/2025-04-01/proxyoperations/method_workspaceslistnotebookkeys.go new file mode 100644 index 00000000000..4c265812b9f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/proxyoperations/method_workspaceslistnotebookkeys.go @@ -0,0 +1,54 @@ +package proxyoperations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspacesListNotebookKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ListNotebookKeysResult +} + +// WorkspacesListNotebookKeys ... +func (c ProxyOperationsClient) WorkspacesListNotebookKeys(ctx context.Context, id WorkspaceId) (result WorkspacesListNotebookKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listNotebookKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ListNotebookKeysResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/proxyoperations/method_workspacesliststorageaccountkeys.go b/resource-manager/machinelearningservices/2025-04-01/proxyoperations/method_workspacesliststorageaccountkeys.go new file mode 100644 index 00000000000..34042bf4150 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/proxyoperations/method_workspacesliststorageaccountkeys.go @@ -0,0 +1,54 @@ +package proxyoperations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspacesListStorageAccountKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ListStorageAccountKeysResult +} + +// WorkspacesListStorageAccountKeys ... +func (c ProxyOperationsClient) WorkspacesListStorageAccountKeys(ctx context.Context, id WorkspaceId) (result WorkspacesListStorageAccountKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listStorageAccountKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ListStorageAccountKeysResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/proxyoperations/method_workspacespreparenotebook.go b/resource-manager/machinelearningservices/2025-04-01/proxyoperations/method_workspacespreparenotebook.go new file mode 100644 index 00000000000..54a59a87891 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/proxyoperations/method_workspacespreparenotebook.go @@ -0,0 +1,71 @@ +package proxyoperations + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspacesPrepareNotebookOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *NotebookResourceInfo +} + +// WorkspacesPrepareNotebook ... +func (c ProxyOperationsClient) WorkspacesPrepareNotebook(ctx context.Context, id WorkspaceId) (result WorkspacesPrepareNotebookOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/prepareNotebook", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// WorkspacesPrepareNotebookThenPoll performs WorkspacesPrepareNotebook then polls until it's completed +func (c ProxyOperationsClient) WorkspacesPrepareNotebookThenPoll(ctx context.Context, id WorkspaceId) error { + result, err := c.WorkspacesPrepareNotebook(ctx, id) + if err != nil { + return fmt.Errorf("performing WorkspacesPrepareNotebook: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after WorkspacesPrepareNotebook: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/proxyoperations/model_listnotebookkeysresult.go b/resource-manager/machinelearningservices/2025-04-01/proxyoperations/model_listnotebookkeysresult.go new file mode 100644 index 00000000000..82943d80532 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/proxyoperations/model_listnotebookkeysresult.go @@ -0,0 +1,9 @@ +package proxyoperations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListNotebookKeysResult struct { + PrimaryAccessKey *string `json:"primaryAccessKey,omitempty"` + SecondaryAccessKey *string `json:"secondaryAccessKey,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/proxyoperations/model_liststorageaccountkeysresult.go b/resource-manager/machinelearningservices/2025-04-01/proxyoperations/model_liststorageaccountkeysresult.go new file mode 100644 index 00000000000..53f0290095a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/proxyoperations/model_liststorageaccountkeysresult.go @@ -0,0 +1,8 @@ +package proxyoperations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListStorageAccountKeysResult struct { + UserStorageKey *string `json:"userStorageKey,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/proxyoperations/model_notebookpreparationerror.go b/resource-manager/machinelearningservices/2025-04-01/proxyoperations/model_notebookpreparationerror.go new file mode 100644 index 00000000000..c9ecad16540 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/proxyoperations/model_notebookpreparationerror.go @@ -0,0 +1,9 @@ +package proxyoperations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NotebookPreparationError struct { + ErrorMessage *string `json:"errorMessage,omitempty"` + StatusCode *int64 `json:"statusCode,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/proxyoperations/model_notebookresourceinfo.go b/resource-manager/machinelearningservices/2025-04-01/proxyoperations/model_notebookresourceinfo.go new file mode 100644 index 00000000000..e6e3629f74f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/proxyoperations/model_notebookresourceinfo.go @@ -0,0 +1,10 @@ +package proxyoperations + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NotebookResourceInfo struct { + Fqdn *string `json:"fqdn,omitempty"` + NotebookPreparationError *NotebookPreparationError `json:"notebookPreparationError,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/proxyoperations/version.go b/resource-manager/machinelearningservices/2025-04-01/proxyoperations/version.go new file mode 100644 index 00000000000..fde730e190d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/proxyoperations/version.go @@ -0,0 +1,10 @@ +package proxyoperations + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/proxyoperations/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/quota/README.md b/resource-manager/machinelearningservices/2025-04-01/quota/README.md new file mode 100644 index 00000000000..71fef3045af --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/quota/README.md @@ -0,0 +1,59 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/quota` Documentation + +The `quota` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/quota" +``` + + +### Client Initialization + +```go +client := quota.NewQuotaClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `QuotaClient.List` + +```go +ctx := context.TODO() +id := quota.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +// 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: `QuotaClient.Update` + +```go +ctx := context.TODO() +id := quota.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +payload := quota.QuotaUpdateParameters{ + // ... +} + + +// alternatively `client.Update(ctx, id, payload)` can be used to do batched pagination +items, err := client.UpdateComplete(ctx, id, payload) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/quota/client.go b/resource-manager/machinelearningservices/2025-04-01/quota/client.go new file mode 100644 index 00000000000..614e0b4f882 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/quota/client.go @@ -0,0 +1,26 @@ +package quota + +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 QuotaClient struct { + Client *resourcemanager.Client +} + +func NewQuotaClientWithBaseURI(sdkApi sdkEnv.Api) (*QuotaClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "quota", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating QuotaClient: %+v", err) + } + + return &QuotaClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/quota/constants.go b/resource-manager/machinelearningservices/2025-04-01/quota/constants.go new file mode 100644 index 00000000000..43d0c58a5ca --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/quota/constants.go @@ -0,0 +1,107 @@ +package quota + +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 QuotaUnit string + +const ( + QuotaUnitCount QuotaUnit = "Count" +) + +func PossibleValuesForQuotaUnit() []string { + return []string{ + string(QuotaUnitCount), + } +} + +func (s *QuotaUnit) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseQuotaUnit(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseQuotaUnit(input string) (*QuotaUnit, error) { + vals := map[string]QuotaUnit{ + "count": QuotaUnitCount, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := QuotaUnit(input) + return &out, nil +} + +type Status string + +const ( + StatusFailure Status = "Failure" + StatusInvalidQuotaBelowClusterMinimum Status = "InvalidQuotaBelowClusterMinimum" + StatusInvalidQuotaExceedsSubscriptionLimit Status = "InvalidQuotaExceedsSubscriptionLimit" + StatusInvalidVMFamilyName Status = "InvalidVMFamilyName" + StatusOperationNotEnabledForRegion Status = "OperationNotEnabledForRegion" + StatusOperationNotSupportedForSku Status = "OperationNotSupportedForSku" + StatusSuccess Status = "Success" + StatusUndefined Status = "Undefined" +) + +func PossibleValuesForStatus() []string { + return []string{ + string(StatusFailure), + string(StatusInvalidQuotaBelowClusterMinimum), + string(StatusInvalidQuotaExceedsSubscriptionLimit), + string(StatusInvalidVMFamilyName), + string(StatusOperationNotEnabledForRegion), + string(StatusOperationNotSupportedForSku), + string(StatusSuccess), + string(StatusUndefined), + } +} + +func (s *Status) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStatus(input string) (*Status, error) { + vals := map[string]Status{ + "failure": StatusFailure, + "invalidquotabelowclusterminimum": StatusInvalidQuotaBelowClusterMinimum, + "invalidquotaexceedssubscriptionlimit": StatusInvalidQuotaExceedsSubscriptionLimit, + "invalidvmfamilyname": StatusInvalidVMFamilyName, + "operationnotenabledforregion": StatusOperationNotEnabledForRegion, + "operationnotsupportedforsku": StatusOperationNotSupportedForSku, + "success": StatusSuccess, + "undefined": StatusUndefined, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Status(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/quota/id_location.go b/resource-manager/machinelearningservices/2025-04-01/quota/id_location.go new file mode 100644 index 00000000000..dc72f0e3fbd --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/quota/id_location.go @@ -0,0 +1,121 @@ +package quota + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) 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.MachineLearningServices/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("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + 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/machinelearningservices/2025-04-01/quota/id_location_test.go b/resource-manager/machinelearningservices/2025-04-01/quota/id_location_test.go new file mode 100644 index 00000000000..2103a9601c0 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/quota/id_location_test.go @@ -0,0 +1,237 @@ +package quota + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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.MachineLearningServices/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.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MachineLearningServices/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MachineLearningServices/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.MachineLearningServices/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.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MachineLearningServices/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MachineLearningServices/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.MachineLearningServices/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/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.mAcHiNeLeArNiNgSeRvIcEs/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/machinelearningservices/2025-04-01/quota/method_list.go b/resource-manager/machinelearningservices/2025-04-01/quota/method_list.go new file mode 100644 index 00000000000..2727508aaab --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/quota/method_list.go @@ -0,0 +1,105 @@ +package quota + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]ResourceQuota +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ResourceQuota +} + +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 QuotaClient) List(ctx context.Context, id LocationId) (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/quotas", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ResourceQuota `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 QuotaClient) ListComplete(ctx context.Context, id LocationId) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, ResourceQuotaOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c QuotaClient) ListCompleteMatchingPredicate(ctx context.Context, id LocationId, predicate ResourceQuotaOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ResourceQuota, 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/machinelearningservices/2025-04-01/quota/method_update.go b/resource-manager/machinelearningservices/2025-04-01/quota/method_update.go new file mode 100644 index 00000000000..3320af708de --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/quota/method_update.go @@ -0,0 +1,105 @@ +package quota + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]UpdateWorkspaceQuotas +} + +type UpdateCompleteResult struct { + LatestHttpResponse *http.Response + Items []UpdateWorkspaceQuotas +} + +type UpdateCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *UpdateCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// Update ... +func (c QuotaClient) Update(ctx context.Context, id LocationId, input QuotaUpdateParameters) (result UpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Pager: &UpdateCustomPager{}, + Path: fmt.Sprintf("%s/updateQuotas", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]UpdateWorkspaceQuotas `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// UpdateComplete retrieves all the results into a single object +func (c QuotaClient) UpdateComplete(ctx context.Context, id LocationId, input QuotaUpdateParameters) (UpdateCompleteResult, error) { + return c.UpdateCompleteMatchingPredicate(ctx, id, input, UpdateWorkspaceQuotasOperationPredicate{}) +} + +// UpdateCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c QuotaClient) UpdateCompleteMatchingPredicate(ctx context.Context, id LocationId, input QuotaUpdateParameters, predicate UpdateWorkspaceQuotasOperationPredicate) (result UpdateCompleteResult, err error) { + items := make([]UpdateWorkspaceQuotas, 0) + + resp, err := c.Update(ctx, id, input) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = UpdateCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/quota/model_quotabaseproperties.go b/resource-manager/machinelearningservices/2025-04-01/quota/model_quotabaseproperties.go new file mode 100644 index 00000000000..12251897521 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/quota/model_quotabaseproperties.go @@ -0,0 +1,11 @@ +package quota + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QuotaBaseProperties struct { + Id *string `json:"id,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Type *string `json:"type,omitempty"` + Unit *QuotaUnit `json:"unit,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/quota/model_quotaupdateparameters.go b/resource-manager/machinelearningservices/2025-04-01/quota/model_quotaupdateparameters.go new file mode 100644 index 00000000000..f6e728e5896 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/quota/model_quotaupdateparameters.go @@ -0,0 +1,9 @@ +package quota + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QuotaUpdateParameters struct { + Location *string `json:"location,omitempty"` + Value *[]QuotaBaseProperties `json:"value,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/quota/model_resourcename.go b/resource-manager/machinelearningservices/2025-04-01/quota/model_resourcename.go new file mode 100644 index 00000000000..99475457983 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/quota/model_resourcename.go @@ -0,0 +1,9 @@ +package quota + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceName struct { + LocalizedValue *string `json:"localizedValue,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/quota/model_resourcequota.go b/resource-manager/machinelearningservices/2025-04-01/quota/model_resourcequota.go new file mode 100644 index 00000000000..3c8167a8375 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/quota/model_resourcequota.go @@ -0,0 +1,13 @@ +package quota + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceQuota struct { + AmlWorkspaceLocation *string `json:"amlWorkspaceLocation,omitempty"` + Id *string `json:"id,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Name *ResourceName `json:"name,omitempty"` + Type *string `json:"type,omitempty"` + Unit *QuotaUnit `json:"unit,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/quota/model_updateworkspacequotas.go b/resource-manager/machinelearningservices/2025-04-01/quota/model_updateworkspacequotas.go new file mode 100644 index 00000000000..9fcf2508f5e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/quota/model_updateworkspacequotas.go @@ -0,0 +1,12 @@ +package quota + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type UpdateWorkspaceQuotas struct { + Id *string `json:"id,omitempty"` + Limit *int64 `json:"limit,omitempty"` + Status *Status `json:"status,omitempty"` + Type *string `json:"type,omitempty"` + Unit *QuotaUnit `json:"unit,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/quota/predicates.go b/resource-manager/machinelearningservices/2025-04-01/quota/predicates.go new file mode 100644 index 00000000000..db56a8407ce --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/quota/predicates.go @@ -0,0 +1,55 @@ +package quota + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResourceQuotaOperationPredicate struct { + AmlWorkspaceLocation *string + Id *string + Limit *int64 + Type *string +} + +func (p ResourceQuotaOperationPredicate) Matches(input ResourceQuota) bool { + + if p.AmlWorkspaceLocation != nil && (input.AmlWorkspaceLocation == nil || *p.AmlWorkspaceLocation != *input.AmlWorkspaceLocation) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Limit != nil && (input.Limit == nil || *p.Limit != *input.Limit) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} + +type UpdateWorkspaceQuotasOperationPredicate struct { + Id *string + Limit *int64 + Type *string +} + +func (p UpdateWorkspaceQuotasOperationPredicate) Matches(input UpdateWorkspaceQuotas) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Limit != nil && (input.Limit == nil || *p.Limit != *input.Limit) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/machinelearningservices/2025-04-01/quota/version.go b/resource-manager/machinelearningservices/2025-04-01/quota/version.go new file mode 100644 index 00000000000..1b4b07b24e9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/quota/version.go @@ -0,0 +1,10 @@ +package quota + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/quota/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/README.md b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/README.md new file mode 100644 index 00000000000..5d9b9c0b7d4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/README.md @@ -0,0 +1,138 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/registrymanagement` Documentation + +The `registrymanagement` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/registrymanagement" +``` + + +### Client Initialization + +```go +client := registrymanagement.NewRegistryManagementClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `RegistryManagementClient.RegistriesCreateOrUpdate` + +```go +ctx := context.TODO() +id := registrymanagement.NewRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName") + +payload := registrymanagement.RegistryTrackedResource{ + // ... +} + + +if err := client.RegistriesCreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `RegistryManagementClient.RegistriesDelete` + +```go +ctx := context.TODO() +id := registrymanagement.NewRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName") + +if err := client.RegistriesDeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `RegistryManagementClient.RegistriesGet` + +```go +ctx := context.TODO() +id := registrymanagement.NewRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName") + +read, err := client.RegistriesGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `RegistryManagementClient.RegistriesList` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.RegistriesList(ctx, id)` can be used to do batched pagination +items, err := client.RegistriesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RegistryManagementClient.RegistriesListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.RegistriesListBySubscription(ctx, id)` can be used to do batched pagination +items, err := client.RegistriesListBySubscriptionComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `RegistryManagementClient.RegistriesRemoveRegions` + +```go +ctx := context.TODO() +id := registrymanagement.NewRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName") + +payload := registrymanagement.RegistryTrackedResource{ + // ... +} + + +if err := client.RegistriesRemoveRegionsThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `RegistryManagementClient.RegistriesUpdate` + +```go +ctx := context.TODO() +id := registrymanagement.NewRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName") + +payload := registrymanagement.PartialRegistryPartialTrackedResource{ + // ... +} + + +read, err := client.RegistriesUpdate(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/machinelearningservices/2025-04-01/registrymanagement/client.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/client.go new file mode 100644 index 00000000000..b9770b7e4d2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/client.go @@ -0,0 +1,26 @@ +package registrymanagement + +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 RegistryManagementClient struct { + Client *resourcemanager.Client +} + +func NewRegistryManagementClientWithBaseURI(sdkApi sdkEnv.Api) (*RegistryManagementClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "registrymanagement", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating RegistryManagementClient: %+v", err) + } + + return &RegistryManagementClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/constants.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/constants.go new file mode 100644 index 00000000000..a9932151720 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/constants.go @@ -0,0 +1,104 @@ +package registrymanagement + +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 EndpointServiceConnectionStatus string + +const ( + EndpointServiceConnectionStatusApproved EndpointServiceConnectionStatus = "Approved" + EndpointServiceConnectionStatusDisconnected EndpointServiceConnectionStatus = "Disconnected" + EndpointServiceConnectionStatusPending EndpointServiceConnectionStatus = "Pending" + EndpointServiceConnectionStatusRejected EndpointServiceConnectionStatus = "Rejected" +) + +func PossibleValuesForEndpointServiceConnectionStatus() []string { + return []string{ + string(EndpointServiceConnectionStatusApproved), + string(EndpointServiceConnectionStatusDisconnected), + string(EndpointServiceConnectionStatusPending), + string(EndpointServiceConnectionStatusRejected), + } +} + +func (s *EndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEndpointServiceConnectionStatus(input string) (*EndpointServiceConnectionStatus, error) { + vals := map[string]EndpointServiceConnectionStatus{ + "approved": EndpointServiceConnectionStatusApproved, + "disconnected": EndpointServiceConnectionStatusDisconnected, + "pending": EndpointServiceConnectionStatusPending, + "rejected": EndpointServiceConnectionStatusRejected, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EndpointServiceConnectionStatus(input) + return &out, nil +} + +type SkuTier string + +const ( + SkuTierBasic SkuTier = "Basic" + SkuTierFree SkuTier = "Free" + SkuTierPremium SkuTier = "Premium" + SkuTierStandard SkuTier = "Standard" +) + +func PossibleValuesForSkuTier() []string { + return []string{ + string(SkuTierBasic), + string(SkuTierFree), + string(SkuTierPremium), + string(SkuTierStandard), + } +} + +func (s *SkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuTier(input string) (*SkuTier, error) { + vals := map[string]SkuTier{ + "basic": SkuTierBasic, + "free": SkuTierFree, + "premium": SkuTierPremium, + "standard": SkuTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuTier(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/id_registry.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/id_registry.go new file mode 100644 index 00000000000..402a0be3312 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/id_registry.go @@ -0,0 +1,130 @@ +package registrymanagement + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&RegistryId{}) +} + +var _ resourceids.ResourceId = &RegistryId{} + +// RegistryId is a struct representing the Resource ID for a Registry +type RegistryId struct { + SubscriptionId string + ResourceGroupName string + RegistryName string +} + +// NewRegistryID returns a new RegistryId struct +func NewRegistryID(subscriptionId string, resourceGroupName string, registryName string) RegistryId { + return RegistryId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + RegistryName: registryName, + } +} + +// ParseRegistryID parses 'input' into a RegistryId +func ParseRegistryID(input string) (*RegistryId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseRegistryIDInsensitively parses 'input' case-insensitively into a RegistryId +// note: this method should only be used for API response data and not user input +func ParseRegistryIDInsensitively(input string) (*RegistryId, error) { + parser := resourceids.NewParserFromResourceIdType(&RegistryId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := RegistryId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *RegistryId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.RegistryName, ok = input.Parsed["registryName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "registryName", input) + } + + return nil +} + +// ValidateRegistryID checks that 'input' can be parsed as a Registry ID +func ValidateRegistryID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseRegistryID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Registry ID +func (id RegistryId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/registries/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.RegistryName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Registry ID +func (id RegistryId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticRegistries", "registries", "registries"), + resourceids.UserSpecifiedSegment("registryName", "registryName"), + } +} + +// String returns a human-readable description of this Registry ID +func (id RegistryId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Registry Name: %q", id.RegistryName), + } + return fmt.Sprintf("Registry (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/id_registry_test.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/id_registry_test.go new file mode 100644 index 00000000000..8a6f399f52d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/id_registry_test.go @@ -0,0 +1,282 @@ +package registrymanagement + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &RegistryId{} + +func TestNewRegistryID(t *testing.T) { + id := NewRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.RegistryName != "registryName" { + t.Fatalf("Expected %q but got %q for Segment 'RegistryName'", id.RegistryName, "registryName") + } +} + +func TestFormatRegistryID(t *testing.T) { + actual := NewRegistryID("12345678-1234-9876-4563-123456789012", "example-resource-group", "registryName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseRegistryID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Expected: &RegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + } +} + +func TestParseRegistryIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *RegistryId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName", + Expected: &RegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + RegistryName: "registryName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/registries/registryName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE", + Expected: &RegistryId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + RegistryName: "rEgIsTrYnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/rEgIsTrIeS/rEgIsTrYnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseRegistryIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.RegistryName != v.Expected.RegistryName { + t.Fatalf("Expected %q but got %q for RegistryName", v.Expected.RegistryName, actual.RegistryName) + } + + } +} + +func TestSegmentsForRegistryId(t *testing.T) { + segments := RegistryId{}.Segments() + if len(segments) == 0 { + t.Fatalf("RegistryId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/method_registriescreateorupdate.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/method_registriescreateorupdate.go new file mode 100644 index 00000000000..3fdf90ab415 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/method_registriescreateorupdate.go @@ -0,0 +1,75 @@ +package registrymanagement + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistriesCreateOrUpdateOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RegistryTrackedResource +} + +// RegistriesCreateOrUpdate ... +func (c RegistryManagementClient) RegistriesCreateOrUpdate(ctx context.Context, id RegistryId, input RegistryTrackedResource) (result RegistriesCreateOrUpdateOperationResponse, 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 +} + +// RegistriesCreateOrUpdateThenPoll performs RegistriesCreateOrUpdate then polls until it's completed +func (c RegistryManagementClient) RegistriesCreateOrUpdateThenPoll(ctx context.Context, id RegistryId, input RegistryTrackedResource) error { + result, err := c.RegistriesCreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RegistriesCreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegistriesCreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/method_registriesdelete.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/method_registriesdelete.go new file mode 100644 index 00000000000..8ffe2dd76ee --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/method_registriesdelete.go @@ -0,0 +1,71 @@ +package registrymanagement + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistriesDeleteOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// RegistriesDelete ... +func (c RegistryManagementClient) RegistriesDelete(ctx context.Context, id RegistryId) (result RegistriesDeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RegistriesDeleteThenPoll performs RegistriesDelete then polls until it's completed +func (c RegistryManagementClient) RegistriesDeleteThenPoll(ctx context.Context, id RegistryId) error { + result, err := c.RegistriesDelete(ctx, id) + if err != nil { + return fmt.Errorf("performing RegistriesDelete: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegistriesDelete: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/method_registriesget.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/method_registriesget.go new file mode 100644 index 00000000000..497541822ad --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/method_registriesget.go @@ -0,0 +1,53 @@ +package registrymanagement + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistriesGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RegistryTrackedResource +} + +// RegistriesGet ... +func (c RegistryManagementClient) RegistriesGet(ctx context.Context, id RegistryId) (result RegistriesGetOperationResponse, 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 RegistryTrackedResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/method_registrieslist.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/method_registrieslist.go new file mode 100644 index 00000000000..e270ec236c6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/method_registrieslist.go @@ -0,0 +1,106 @@ +package registrymanagement + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistriesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RegistryTrackedResource +} + +type RegistriesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []RegistryTrackedResource +} + +type RegistriesListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *RegistriesListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// RegistriesList ... +func (c RegistryManagementClient) RegistriesList(ctx context.Context, id commonids.ResourceGroupId) (result RegistriesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &RegistriesListCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.MachineLearningServices/registries", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RegistryTrackedResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RegistriesListComplete retrieves all the results into a single object +func (c RegistryManagementClient) RegistriesListComplete(ctx context.Context, id commonids.ResourceGroupId) (RegistriesListCompleteResult, error) { + return c.RegistriesListCompleteMatchingPredicate(ctx, id, RegistryTrackedResourceOperationPredicate{}) +} + +// RegistriesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RegistryManagementClient) RegistriesListCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, predicate RegistryTrackedResourceOperationPredicate) (result RegistriesListCompleteResult, err error) { + items := make([]RegistryTrackedResource, 0) + + resp, err := c.RegistriesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = RegistriesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/method_registrieslistbysubscription.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/method_registrieslistbysubscription.go new file mode 100644 index 00000000000..e98d4517961 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/method_registrieslistbysubscription.go @@ -0,0 +1,106 @@ +package registrymanagement + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistriesListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]RegistryTrackedResource +} + +type RegistriesListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []RegistryTrackedResource +} + +type RegistriesListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *RegistriesListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// RegistriesListBySubscription ... +func (c RegistryManagementClient) RegistriesListBySubscription(ctx context.Context, id commonids.SubscriptionId) (result RegistriesListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &RegistriesListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.MachineLearningServices/registries", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]RegistryTrackedResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// RegistriesListBySubscriptionComplete retrieves all the results into a single object +func (c RegistryManagementClient) RegistriesListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId) (RegistriesListBySubscriptionCompleteResult, error) { + return c.RegistriesListBySubscriptionCompleteMatchingPredicate(ctx, id, RegistryTrackedResourceOperationPredicate{}) +} + +// RegistriesListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c RegistryManagementClient) RegistriesListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, predicate RegistryTrackedResourceOperationPredicate) (result RegistriesListBySubscriptionCompleteResult, err error) { + items := make([]RegistryTrackedResource, 0) + + resp, err := c.RegistriesListBySubscription(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = RegistriesListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/method_registriesremoveregions.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/method_registriesremoveregions.go new file mode 100644 index 00000000000..a71306a15ad --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/method_registriesremoveregions.go @@ -0,0 +1,75 @@ +package registrymanagement + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistriesRemoveRegionsOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *RegistryTrackedResource +} + +// RegistriesRemoveRegions ... +func (c RegistryManagementClient) RegistriesRemoveRegions(ctx context.Context, id RegistryId, input RegistryTrackedResource) (result RegistriesRemoveRegionsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/removeRegions", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RegistriesRemoveRegionsThenPoll performs RegistriesRemoveRegions then polls until it's completed +func (c RegistryManagementClient) RegistriesRemoveRegionsThenPoll(ctx context.Context, id RegistryId, input RegistryTrackedResource) error { + result, err := c.RegistriesRemoveRegions(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RegistriesRemoveRegions: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegistriesRemoveRegions: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/method_registriesupdate.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/method_registriesupdate.go new file mode 100644 index 00000000000..93ee9b6d1e4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/method_registriesupdate.go @@ -0,0 +1,57 @@ +package registrymanagement + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistriesUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *RegistryTrackedResource +} + +// RegistriesUpdate ... +func (c RegistryManagementClient) RegistriesUpdate(ctx context.Context, id RegistryId, input PartialRegistryPartialTrackedResource) (result RegistriesUpdateOperationResponse, 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 RegistryTrackedResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_acrdetails.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_acrdetails.go new file mode 100644 index 00000000000..3c33f4c6008 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_acrdetails.go @@ -0,0 +1,8 @@ +package registrymanagement + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AcrDetails struct { + SystemCreatedAcrAccount *SystemCreatedAcrAccount `json:"systemCreatedAcrAccount,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_armresourceid.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_armresourceid.go new file mode 100644 index 00000000000..42556fc2624 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_armresourceid.go @@ -0,0 +1,8 @@ +package registrymanagement + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ArmResourceId struct { + ResourceId *string `json:"resourceId,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_managedresourcegroupassignedidentities.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_managedresourcegroupassignedidentities.go new file mode 100644 index 00000000000..81a6b3416dc --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_managedresourcegroupassignedidentities.go @@ -0,0 +1,8 @@ +package registrymanagement + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedResourceGroupAssignedIdentities struct { + PrincipalId *string `json:"principalId,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_managedresourcegroupsettings.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_managedresourcegroupsettings.go new file mode 100644 index 00000000000..c3d01ed46bc --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_managedresourcegroupsettings.go @@ -0,0 +1,8 @@ +package registrymanagement + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedResourceGroupSettings struct { + AssignedIdentities *[]ManagedResourceGroupAssignedIdentities `json:"assignedIdentities,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_partialregistrypartialtrackedresource.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_partialregistrypartialtrackedresource.go new file mode 100644 index 00000000000..b05636664c6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_partialregistrypartialtrackedresource.go @@ -0,0 +1,14 @@ +package registrymanagement + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PartialRegistryPartialTrackedResource struct { + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Sku *PartialSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_partialsku.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_partialsku.go new file mode 100644 index 00000000000..064728e0898 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_partialsku.go @@ -0,0 +1,12 @@ +package registrymanagement + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PartialSku struct { + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Name *string `json:"name,omitempty"` + Size *string `json:"size,omitempty"` + Tier *SkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_privateendpointresource.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_privateendpointresource.go new file mode 100644 index 00000000000..4f330afbbc6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_privateendpointresource.go @@ -0,0 +1,9 @@ +package registrymanagement + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointResource struct { + Id *string `json:"id,omitempty"` + SubnetArmId *string `json:"subnetArmId,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_registry.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_registry.go new file mode 100644 index 00000000000..ff07ae4f321 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_registry.go @@ -0,0 +1,15 @@ +package registrymanagement + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Registry struct { + DiscoveryURL *string `json:"discoveryUrl,omitempty"` + IntellectualPropertyPublisher *string `json:"intellectualPropertyPublisher,omitempty"` + ManagedResourceGroup *ArmResourceId `json:"managedResourceGroup,omitempty"` + ManagedResourceGroupSettings *ManagedResourceGroupSettings `json:"managedResourceGroupSettings,omitempty"` + MlFlowRegistryUri *string `json:"mlFlowRegistryUri,omitempty"` + PublicNetworkAccess *string `json:"publicNetworkAccess,omitempty"` + RegionDetails *[]RegistryRegionArmDetails `json:"regionDetails,omitempty"` + RegistryPrivateEndpointConnections *[]RegistryPrivateEndpointConnection `json:"registryPrivateEndpointConnections,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_registryprivateendpointconnection.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_registryprivateendpointconnection.go new file mode 100644 index 00000000000..e1a2204bdb6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_registryprivateendpointconnection.go @@ -0,0 +1,10 @@ +package registrymanagement + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryPrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Location *string `json:"location,omitempty"` + Properties *RegistryPrivateEndpointConnectionProperties `json:"properties,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_registryprivateendpointconnectionproperties.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_registryprivateendpointconnectionproperties.go new file mode 100644 index 00000000000..a7bd993d731 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_registryprivateendpointconnectionproperties.go @@ -0,0 +1,11 @@ +package registrymanagement + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryPrivateEndpointConnectionProperties struct { + GroupIds *[]string `json:"groupIds,omitempty"` + PrivateEndpoint *PrivateEndpointResource `json:"privateEndpoint,omitempty"` + ProvisioningState *string `json:"provisioningState,omitempty"` + RegistryPrivateLinkServiceConnectionState *RegistryPrivateLinkServiceConnectionState `json:"registryPrivateLinkServiceConnectionState,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_registryprivatelinkserviceconnectionstate.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_registryprivatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..fd2059b5304 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_registryprivatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package registrymanagement + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryPrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *EndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_registryregionarmdetails.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_registryregionarmdetails.go new file mode 100644 index 00000000000..07f7c39efdb --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_registryregionarmdetails.go @@ -0,0 +1,10 @@ +package registrymanagement + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryRegionArmDetails struct { + AcrDetails *[]AcrDetails `json:"acrDetails,omitempty"` + Location *string `json:"location,omitempty"` + StorageAccountDetails *[]StorageAccountDetails `json:"storageAccountDetails,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_registrytrackedresource.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_registrytrackedresource.go new file mode 100644 index 00000000000..0e8065d6e30 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_registrytrackedresource.go @@ -0,0 +1,22 @@ +package registrymanagement + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryTrackedResource struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties Registry `json:"properties"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_sku.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_sku.go new file mode 100644 index 00000000000..d4c11622763 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_sku.go @@ -0,0 +1,12 @@ +package registrymanagement + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Name string `json:"name"` + Size *string `json:"size,omitempty"` + Tier *SkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_storageaccountdetails.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_storageaccountdetails.go new file mode 100644 index 00000000000..a727790a017 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_storageaccountdetails.go @@ -0,0 +1,8 @@ +package registrymanagement + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StorageAccountDetails struct { + SystemCreatedStorageAccount *SystemCreatedStorageAccount `json:"systemCreatedStorageAccount,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_systemcreatedacraccount.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_systemcreatedacraccount.go new file mode 100644 index 00000000000..b35c9c4521e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_systemcreatedacraccount.go @@ -0,0 +1,10 @@ +package registrymanagement + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SystemCreatedAcrAccount struct { + AcrAccountName *string `json:"acrAccountName,omitempty"` + AcrAccountSku *string `json:"acrAccountSku,omitempty"` + ArmResourceId *ArmResourceId `json:"armResourceId,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_systemcreatedstorageaccount.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_systemcreatedstorageaccount.go new file mode 100644 index 00000000000..09b6498fbb4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/model_systemcreatedstorageaccount.go @@ -0,0 +1,12 @@ +package registrymanagement + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SystemCreatedStorageAccount struct { + AllowBlobPublicAccess *bool `json:"allowBlobPublicAccess,omitempty"` + ArmResourceId *ArmResourceId `json:"armResourceId,omitempty"` + StorageAccountHnsEnabled *bool `json:"storageAccountHnsEnabled,omitempty"` + StorageAccountName *string `json:"storageAccountName,omitempty"` + StorageAccountType *string `json:"storageAccountType,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/predicates.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/predicates.go new file mode 100644 index 00000000000..4f190d2b8d3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/predicates.go @@ -0,0 +1,37 @@ +package registrymanagement + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryTrackedResourceOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p RegistryTrackedResourceOperationPredicate) Matches(input RegistryTrackedResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/machinelearningservices/2025-04-01/registrymanagement/version.go b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/version.go new file mode 100644 index 00000000000..78a78c1b757 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/registrymanagement/version.go @@ -0,0 +1,10 @@ +package registrymanagement + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/registrymanagement/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/README.md b/resource-manager/machinelearningservices/2025-04-01/schedule/README.md new file mode 100644 index 00000000000..5e0745827e8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/README.md @@ -0,0 +1,82 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/schedule` Documentation + +The `schedule` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/schedule" +``` + + +### Client Initialization + +```go +client := schedule.NewScheduleClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ScheduleClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := schedule.NewScheduleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "scheduleName") + +payload := schedule.ScheduleResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ScheduleClient.Delete` + +```go +ctx := context.TODO() +id := schedule.NewScheduleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "scheduleName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ScheduleClient.Get` + +```go +ctx := context.TODO() +id := schedule.NewScheduleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "scheduleName") + +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: `ScheduleClient.List` + +```go +ctx := context.TODO() +id := schedule.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +// alternatively `client.List(ctx, id, schedule.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, schedule.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/client.go b/resource-manager/machinelearningservices/2025-04-01/schedule/client.go new file mode 100644 index 00000000000..5f8bfedb043 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/client.go @@ -0,0 +1,26 @@ +package schedule + +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 ScheduleClient struct { + Client *resourcemanager.Client +} + +func NewScheduleClientWithBaseURI(sdkApi sdkEnv.Api) (*ScheduleClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "schedule", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ScheduleClient: %+v", err) + } + + return &ScheduleClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/constants.go b/resource-manager/machinelearningservices/2025-04-01/schedule/constants.go new file mode 100644 index 00000000000..21dcab17d12 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/constants.go @@ -0,0 +1,3192 @@ +package schedule + +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 BlockedTransformers string + +const ( + BlockedTransformersCatTargetEncoder BlockedTransformers = "CatTargetEncoder" + BlockedTransformersCountVectorizer BlockedTransformers = "CountVectorizer" + BlockedTransformersHashOneHotEncoder BlockedTransformers = "HashOneHotEncoder" + BlockedTransformersLabelEncoder BlockedTransformers = "LabelEncoder" + BlockedTransformersNaiveBayes BlockedTransformers = "NaiveBayes" + BlockedTransformersOneHotEncoder BlockedTransformers = "OneHotEncoder" + BlockedTransformersTextTargetEncoder BlockedTransformers = "TextTargetEncoder" + BlockedTransformersTfIdf BlockedTransformers = "TfIdf" + BlockedTransformersWoETargetEncoder BlockedTransformers = "WoETargetEncoder" + BlockedTransformersWordEmbedding BlockedTransformers = "WordEmbedding" +) + +func PossibleValuesForBlockedTransformers() []string { + return []string{ + string(BlockedTransformersCatTargetEncoder), + string(BlockedTransformersCountVectorizer), + string(BlockedTransformersHashOneHotEncoder), + string(BlockedTransformersLabelEncoder), + string(BlockedTransformersNaiveBayes), + string(BlockedTransformersOneHotEncoder), + string(BlockedTransformersTextTargetEncoder), + string(BlockedTransformersTfIdf), + string(BlockedTransformersWoETargetEncoder), + string(BlockedTransformersWordEmbedding), + } +} + +func (s *BlockedTransformers) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBlockedTransformers(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBlockedTransformers(input string) (*BlockedTransformers, error) { + vals := map[string]BlockedTransformers{ + "cattargetencoder": BlockedTransformersCatTargetEncoder, + "countvectorizer": BlockedTransformersCountVectorizer, + "hashonehotencoder": BlockedTransformersHashOneHotEncoder, + "labelencoder": BlockedTransformersLabelEncoder, + "naivebayes": BlockedTransformersNaiveBayes, + "onehotencoder": BlockedTransformersOneHotEncoder, + "texttargetencoder": BlockedTransformersTextTargetEncoder, + "tfidf": BlockedTransformersTfIdf, + "woetargetencoder": BlockedTransformersWoETargetEncoder, + "wordembedding": BlockedTransformersWordEmbedding, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BlockedTransformers(input) + return &out, nil +} + +type CategoricalDataDriftMetric string + +const ( + CategoricalDataDriftMetricJensenShannonDistance CategoricalDataDriftMetric = "JensenShannonDistance" + CategoricalDataDriftMetricPearsonsChiSquaredTest CategoricalDataDriftMetric = "PearsonsChiSquaredTest" + CategoricalDataDriftMetricPopulationStabilityIndex CategoricalDataDriftMetric = "PopulationStabilityIndex" +) + +func PossibleValuesForCategoricalDataDriftMetric() []string { + return []string{ + string(CategoricalDataDriftMetricJensenShannonDistance), + string(CategoricalDataDriftMetricPearsonsChiSquaredTest), + string(CategoricalDataDriftMetricPopulationStabilityIndex), + } +} + +func (s *CategoricalDataDriftMetric) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCategoricalDataDriftMetric(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCategoricalDataDriftMetric(input string) (*CategoricalDataDriftMetric, error) { + vals := map[string]CategoricalDataDriftMetric{ + "jensenshannondistance": CategoricalDataDriftMetricJensenShannonDistance, + "pearsonschisquaredtest": CategoricalDataDriftMetricPearsonsChiSquaredTest, + "populationstabilityindex": CategoricalDataDriftMetricPopulationStabilityIndex, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CategoricalDataDriftMetric(input) + return &out, nil +} + +type CategoricalDataQualityMetric string + +const ( + CategoricalDataQualityMetricDataTypeErrorRate CategoricalDataQualityMetric = "DataTypeErrorRate" + CategoricalDataQualityMetricNullValueRate CategoricalDataQualityMetric = "NullValueRate" + CategoricalDataQualityMetricOutOfBoundsRate CategoricalDataQualityMetric = "OutOfBoundsRate" +) + +func PossibleValuesForCategoricalDataQualityMetric() []string { + return []string{ + string(CategoricalDataQualityMetricDataTypeErrorRate), + string(CategoricalDataQualityMetricNullValueRate), + string(CategoricalDataQualityMetricOutOfBoundsRate), + } +} + +func (s *CategoricalDataQualityMetric) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCategoricalDataQualityMetric(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCategoricalDataQualityMetric(input string) (*CategoricalDataQualityMetric, error) { + vals := map[string]CategoricalDataQualityMetric{ + "datatypeerrorrate": CategoricalDataQualityMetricDataTypeErrorRate, + "nullvaluerate": CategoricalDataQualityMetricNullValueRate, + "outofboundsrate": CategoricalDataQualityMetricOutOfBoundsRate, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CategoricalDataQualityMetric(input) + return &out, nil +} + +type CategoricalPredictionDriftMetric string + +const ( + CategoricalPredictionDriftMetricJensenShannonDistance CategoricalPredictionDriftMetric = "JensenShannonDistance" + CategoricalPredictionDriftMetricPearsonsChiSquaredTest CategoricalPredictionDriftMetric = "PearsonsChiSquaredTest" + CategoricalPredictionDriftMetricPopulationStabilityIndex CategoricalPredictionDriftMetric = "PopulationStabilityIndex" +) + +func PossibleValuesForCategoricalPredictionDriftMetric() []string { + return []string{ + string(CategoricalPredictionDriftMetricJensenShannonDistance), + string(CategoricalPredictionDriftMetricPearsonsChiSquaredTest), + string(CategoricalPredictionDriftMetricPopulationStabilityIndex), + } +} + +func (s *CategoricalPredictionDriftMetric) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseCategoricalPredictionDriftMetric(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseCategoricalPredictionDriftMetric(input string) (*CategoricalPredictionDriftMetric, error) { + vals := map[string]CategoricalPredictionDriftMetric{ + "jensenshannondistance": CategoricalPredictionDriftMetricJensenShannonDistance, + "pearsonschisquaredtest": CategoricalPredictionDriftMetricPearsonsChiSquaredTest, + "populationstabilityindex": CategoricalPredictionDriftMetricPopulationStabilityIndex, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := CategoricalPredictionDriftMetric(input) + return &out, nil +} + +type ClassificationModels string + +const ( + ClassificationModelsBernoulliNaiveBayes ClassificationModels = "BernoulliNaiveBayes" + ClassificationModelsDecisionTree ClassificationModels = "DecisionTree" + ClassificationModelsExtremeRandomTrees ClassificationModels = "ExtremeRandomTrees" + ClassificationModelsGradientBoosting ClassificationModels = "GradientBoosting" + ClassificationModelsKNN ClassificationModels = "KNN" + ClassificationModelsLightGBM ClassificationModels = "LightGBM" + ClassificationModelsLinearSVM ClassificationModels = "LinearSVM" + ClassificationModelsLogisticRegression ClassificationModels = "LogisticRegression" + ClassificationModelsMultinomialNaiveBayes ClassificationModels = "MultinomialNaiveBayes" + ClassificationModelsRandomForest ClassificationModels = "RandomForest" + ClassificationModelsSGD ClassificationModels = "SGD" + ClassificationModelsSVM ClassificationModels = "SVM" + ClassificationModelsXGBoostClassifier ClassificationModels = "XGBoostClassifier" +) + +func PossibleValuesForClassificationModels() []string { + return []string{ + string(ClassificationModelsBernoulliNaiveBayes), + string(ClassificationModelsDecisionTree), + string(ClassificationModelsExtremeRandomTrees), + string(ClassificationModelsGradientBoosting), + string(ClassificationModelsKNN), + string(ClassificationModelsLightGBM), + string(ClassificationModelsLinearSVM), + string(ClassificationModelsLogisticRegression), + string(ClassificationModelsMultinomialNaiveBayes), + string(ClassificationModelsRandomForest), + string(ClassificationModelsSGD), + string(ClassificationModelsSVM), + string(ClassificationModelsXGBoostClassifier), + } +} + +func (s *ClassificationModels) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClassificationModels(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClassificationModels(input string) (*ClassificationModels, error) { + vals := map[string]ClassificationModels{ + "bernoullinaivebayes": ClassificationModelsBernoulliNaiveBayes, + "decisiontree": ClassificationModelsDecisionTree, + "extremerandomtrees": ClassificationModelsExtremeRandomTrees, + "gradientboosting": ClassificationModelsGradientBoosting, + "knn": ClassificationModelsKNN, + "lightgbm": ClassificationModelsLightGBM, + "linearsvm": ClassificationModelsLinearSVM, + "logisticregression": ClassificationModelsLogisticRegression, + "multinomialnaivebayes": ClassificationModelsMultinomialNaiveBayes, + "randomforest": ClassificationModelsRandomForest, + "sgd": ClassificationModelsSGD, + "svm": ClassificationModelsSVM, + "xgboostclassifier": ClassificationModelsXGBoostClassifier, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClassificationModels(input) + return &out, nil +} + +type ClassificationMultilabelPrimaryMetrics string + +const ( + ClassificationMultilabelPrimaryMetricsAUCWeighted ClassificationMultilabelPrimaryMetrics = "AUCWeighted" + ClassificationMultilabelPrimaryMetricsAccuracy ClassificationMultilabelPrimaryMetrics = "Accuracy" + ClassificationMultilabelPrimaryMetricsAveragePrecisionScoreWeighted ClassificationMultilabelPrimaryMetrics = "AveragePrecisionScoreWeighted" + ClassificationMultilabelPrimaryMetricsIOU ClassificationMultilabelPrimaryMetrics = "IOU" + ClassificationMultilabelPrimaryMetricsNormMacroRecall ClassificationMultilabelPrimaryMetrics = "NormMacroRecall" + ClassificationMultilabelPrimaryMetricsPrecisionScoreWeighted ClassificationMultilabelPrimaryMetrics = "PrecisionScoreWeighted" +) + +func PossibleValuesForClassificationMultilabelPrimaryMetrics() []string { + return []string{ + string(ClassificationMultilabelPrimaryMetricsAUCWeighted), + string(ClassificationMultilabelPrimaryMetricsAccuracy), + string(ClassificationMultilabelPrimaryMetricsAveragePrecisionScoreWeighted), + string(ClassificationMultilabelPrimaryMetricsIOU), + string(ClassificationMultilabelPrimaryMetricsNormMacroRecall), + string(ClassificationMultilabelPrimaryMetricsPrecisionScoreWeighted), + } +} + +func (s *ClassificationMultilabelPrimaryMetrics) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClassificationMultilabelPrimaryMetrics(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClassificationMultilabelPrimaryMetrics(input string) (*ClassificationMultilabelPrimaryMetrics, error) { + vals := map[string]ClassificationMultilabelPrimaryMetrics{ + "aucweighted": ClassificationMultilabelPrimaryMetricsAUCWeighted, + "accuracy": ClassificationMultilabelPrimaryMetricsAccuracy, + "averageprecisionscoreweighted": ClassificationMultilabelPrimaryMetricsAveragePrecisionScoreWeighted, + "iou": ClassificationMultilabelPrimaryMetricsIOU, + "normmacrorecall": ClassificationMultilabelPrimaryMetricsNormMacroRecall, + "precisionscoreweighted": ClassificationMultilabelPrimaryMetricsPrecisionScoreWeighted, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClassificationMultilabelPrimaryMetrics(input) + return &out, nil +} + +type ClassificationPrimaryMetrics string + +const ( + ClassificationPrimaryMetricsAUCWeighted ClassificationPrimaryMetrics = "AUCWeighted" + ClassificationPrimaryMetricsAccuracy ClassificationPrimaryMetrics = "Accuracy" + ClassificationPrimaryMetricsAveragePrecisionScoreWeighted ClassificationPrimaryMetrics = "AveragePrecisionScoreWeighted" + ClassificationPrimaryMetricsNormMacroRecall ClassificationPrimaryMetrics = "NormMacroRecall" + ClassificationPrimaryMetricsPrecisionScoreWeighted ClassificationPrimaryMetrics = "PrecisionScoreWeighted" +) + +func PossibleValuesForClassificationPrimaryMetrics() []string { + return []string{ + string(ClassificationPrimaryMetricsAUCWeighted), + string(ClassificationPrimaryMetricsAccuracy), + string(ClassificationPrimaryMetricsAveragePrecisionScoreWeighted), + string(ClassificationPrimaryMetricsNormMacroRecall), + string(ClassificationPrimaryMetricsPrecisionScoreWeighted), + } +} + +func (s *ClassificationPrimaryMetrics) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseClassificationPrimaryMetrics(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseClassificationPrimaryMetrics(input string) (*ClassificationPrimaryMetrics, error) { + vals := map[string]ClassificationPrimaryMetrics{ + "aucweighted": ClassificationPrimaryMetricsAUCWeighted, + "accuracy": ClassificationPrimaryMetricsAccuracy, + "averageprecisionscoreweighted": ClassificationPrimaryMetricsAveragePrecisionScoreWeighted, + "normmacrorecall": ClassificationPrimaryMetricsNormMacroRecall, + "precisionscoreweighted": ClassificationPrimaryMetricsPrecisionScoreWeighted, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ClassificationPrimaryMetrics(input) + return &out, nil +} + +type DistributionType string + +const ( + DistributionTypeMpi DistributionType = "Mpi" + DistributionTypePyTorch DistributionType = "PyTorch" + DistributionTypeTensorFlow DistributionType = "TensorFlow" +) + +func PossibleValuesForDistributionType() []string { + return []string{ + string(DistributionTypeMpi), + string(DistributionTypePyTorch), + string(DistributionTypeTensorFlow), + } +} + +func (s *DistributionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDistributionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDistributionType(input string) (*DistributionType, error) { + vals := map[string]DistributionType{ + "mpi": DistributionTypeMpi, + "pytorch": DistributionTypePyTorch, + "tensorflow": DistributionTypeTensorFlow, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DistributionType(input) + return &out, nil +} + +type EarlyTerminationPolicyType string + +const ( + EarlyTerminationPolicyTypeBandit EarlyTerminationPolicyType = "Bandit" + EarlyTerminationPolicyTypeMedianStopping EarlyTerminationPolicyType = "MedianStopping" + EarlyTerminationPolicyTypeTruncationSelection EarlyTerminationPolicyType = "TruncationSelection" +) + +func PossibleValuesForEarlyTerminationPolicyType() []string { + return []string{ + string(EarlyTerminationPolicyTypeBandit), + string(EarlyTerminationPolicyTypeMedianStopping), + string(EarlyTerminationPolicyTypeTruncationSelection), + } +} + +func (s *EarlyTerminationPolicyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEarlyTerminationPolicyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEarlyTerminationPolicyType(input string) (*EarlyTerminationPolicyType, error) { + vals := map[string]EarlyTerminationPolicyType{ + "bandit": EarlyTerminationPolicyTypeBandit, + "medianstopping": EarlyTerminationPolicyTypeMedianStopping, + "truncationselection": EarlyTerminationPolicyTypeTruncationSelection, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EarlyTerminationPolicyType(input) + return &out, nil +} + +type EmailNotificationEnableType string + +const ( + EmailNotificationEnableTypeJobCancelled EmailNotificationEnableType = "JobCancelled" + EmailNotificationEnableTypeJobCompleted EmailNotificationEnableType = "JobCompleted" + EmailNotificationEnableTypeJobFailed EmailNotificationEnableType = "JobFailed" +) + +func PossibleValuesForEmailNotificationEnableType() []string { + return []string{ + string(EmailNotificationEnableTypeJobCancelled), + string(EmailNotificationEnableTypeJobCompleted), + string(EmailNotificationEnableTypeJobFailed), + } +} + +func (s *EmailNotificationEnableType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEmailNotificationEnableType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEmailNotificationEnableType(input string) (*EmailNotificationEnableType, error) { + vals := map[string]EmailNotificationEnableType{ + "jobcancelled": EmailNotificationEnableTypeJobCancelled, + "jobcompleted": EmailNotificationEnableTypeJobCompleted, + "jobfailed": EmailNotificationEnableTypeJobFailed, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EmailNotificationEnableType(input) + return &out, nil +} + +type FeatureAttributionMetric string + +const ( + FeatureAttributionMetricNormalizedDiscountedCumulativeGain FeatureAttributionMetric = "NormalizedDiscountedCumulativeGain" +) + +func PossibleValuesForFeatureAttributionMetric() []string { + return []string{ + string(FeatureAttributionMetricNormalizedDiscountedCumulativeGain), + } +} + +func (s *FeatureAttributionMetric) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFeatureAttributionMetric(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFeatureAttributionMetric(input string) (*FeatureAttributionMetric, error) { + vals := map[string]FeatureAttributionMetric{ + "normalizeddiscountedcumulativegain": FeatureAttributionMetricNormalizedDiscountedCumulativeGain, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FeatureAttributionMetric(input) + return &out, nil +} + +type FeatureImportanceMode string + +const ( + FeatureImportanceModeDisabled FeatureImportanceMode = "Disabled" + FeatureImportanceModeEnabled FeatureImportanceMode = "Enabled" +) + +func PossibleValuesForFeatureImportanceMode() []string { + return []string{ + string(FeatureImportanceModeDisabled), + string(FeatureImportanceModeEnabled), + } +} + +func (s *FeatureImportanceMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFeatureImportanceMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFeatureImportanceMode(input string) (*FeatureImportanceMode, error) { + vals := map[string]FeatureImportanceMode{ + "disabled": FeatureImportanceModeDisabled, + "enabled": FeatureImportanceModeEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FeatureImportanceMode(input) + return &out, nil +} + +type FeatureLags string + +const ( + FeatureLagsAuto FeatureLags = "Auto" + FeatureLagsNone FeatureLags = "None" +) + +func PossibleValuesForFeatureLags() []string { + return []string{ + string(FeatureLagsAuto), + string(FeatureLagsNone), + } +} + +func (s *FeatureLags) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFeatureLags(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFeatureLags(input string) (*FeatureLags, error) { + vals := map[string]FeatureLags{ + "auto": FeatureLagsAuto, + "none": FeatureLagsNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FeatureLags(input) + return &out, nil +} + +type FeaturizationMode string + +const ( + FeaturizationModeAuto FeaturizationMode = "Auto" + FeaturizationModeCustom FeaturizationMode = "Custom" + FeaturizationModeOff FeaturizationMode = "Off" +) + +func PossibleValuesForFeaturizationMode() []string { + return []string{ + string(FeaturizationModeAuto), + string(FeaturizationModeCustom), + string(FeaturizationModeOff), + } +} + +func (s *FeaturizationMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFeaturizationMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFeaturizationMode(input string) (*FeaturizationMode, error) { + vals := map[string]FeaturizationMode{ + "auto": FeaturizationModeAuto, + "custom": FeaturizationModeCustom, + "off": FeaturizationModeOff, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FeaturizationMode(input) + return &out, nil +} + +type ForecastHorizonMode string + +const ( + ForecastHorizonModeAuto ForecastHorizonMode = "Auto" + ForecastHorizonModeCustom ForecastHorizonMode = "Custom" +) + +func PossibleValuesForForecastHorizonMode() []string { + return []string{ + string(ForecastHorizonModeAuto), + string(ForecastHorizonModeCustom), + } +} + +func (s *ForecastHorizonMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseForecastHorizonMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseForecastHorizonMode(input string) (*ForecastHorizonMode, error) { + vals := map[string]ForecastHorizonMode{ + "auto": ForecastHorizonModeAuto, + "custom": ForecastHorizonModeCustom, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ForecastHorizonMode(input) + return &out, nil +} + +type ForecastingModels string + +const ( + ForecastingModelsArimax ForecastingModels = "Arimax" + ForecastingModelsAutoArima ForecastingModels = "AutoArima" + ForecastingModelsAverage ForecastingModels = "Average" + ForecastingModelsDecisionTree ForecastingModels = "DecisionTree" + ForecastingModelsElasticNet ForecastingModels = "ElasticNet" + ForecastingModelsExponentialSmoothing ForecastingModels = "ExponentialSmoothing" + ForecastingModelsExtremeRandomTrees ForecastingModels = "ExtremeRandomTrees" + ForecastingModelsGradientBoosting ForecastingModels = "GradientBoosting" + ForecastingModelsKNN ForecastingModels = "KNN" + ForecastingModelsLassoLars ForecastingModels = "LassoLars" + ForecastingModelsLightGBM ForecastingModels = "LightGBM" + ForecastingModelsNaive ForecastingModels = "Naive" + ForecastingModelsProphet ForecastingModels = "Prophet" + ForecastingModelsRandomForest ForecastingModels = "RandomForest" + ForecastingModelsSGD ForecastingModels = "SGD" + ForecastingModelsSeasonalAverage ForecastingModels = "SeasonalAverage" + ForecastingModelsSeasonalNaive ForecastingModels = "SeasonalNaive" + ForecastingModelsTCNForecaster ForecastingModels = "TCNForecaster" + ForecastingModelsXGBoostRegressor ForecastingModels = "XGBoostRegressor" +) + +func PossibleValuesForForecastingModels() []string { + return []string{ + string(ForecastingModelsArimax), + string(ForecastingModelsAutoArima), + string(ForecastingModelsAverage), + string(ForecastingModelsDecisionTree), + string(ForecastingModelsElasticNet), + string(ForecastingModelsExponentialSmoothing), + string(ForecastingModelsExtremeRandomTrees), + string(ForecastingModelsGradientBoosting), + string(ForecastingModelsKNN), + string(ForecastingModelsLassoLars), + string(ForecastingModelsLightGBM), + string(ForecastingModelsNaive), + string(ForecastingModelsProphet), + string(ForecastingModelsRandomForest), + string(ForecastingModelsSGD), + string(ForecastingModelsSeasonalAverage), + string(ForecastingModelsSeasonalNaive), + string(ForecastingModelsTCNForecaster), + string(ForecastingModelsXGBoostRegressor), + } +} + +func (s *ForecastingModels) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseForecastingModels(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseForecastingModels(input string) (*ForecastingModels, error) { + vals := map[string]ForecastingModels{ + "arimax": ForecastingModelsArimax, + "autoarima": ForecastingModelsAutoArima, + "average": ForecastingModelsAverage, + "decisiontree": ForecastingModelsDecisionTree, + "elasticnet": ForecastingModelsElasticNet, + "exponentialsmoothing": ForecastingModelsExponentialSmoothing, + "extremerandomtrees": ForecastingModelsExtremeRandomTrees, + "gradientboosting": ForecastingModelsGradientBoosting, + "knn": ForecastingModelsKNN, + "lassolars": ForecastingModelsLassoLars, + "lightgbm": ForecastingModelsLightGBM, + "naive": ForecastingModelsNaive, + "prophet": ForecastingModelsProphet, + "randomforest": ForecastingModelsRandomForest, + "sgd": ForecastingModelsSGD, + "seasonalaverage": ForecastingModelsSeasonalAverage, + "seasonalnaive": ForecastingModelsSeasonalNaive, + "tcnforecaster": ForecastingModelsTCNForecaster, + "xgboostregressor": ForecastingModelsXGBoostRegressor, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ForecastingModels(input) + return &out, nil +} + +type ForecastingPrimaryMetrics string + +const ( + ForecastingPrimaryMetricsNormalizedMeanAbsoluteError ForecastingPrimaryMetrics = "NormalizedMeanAbsoluteError" + ForecastingPrimaryMetricsNormalizedRootMeanSquaredError ForecastingPrimaryMetrics = "NormalizedRootMeanSquaredError" + ForecastingPrimaryMetricsRTwoScore ForecastingPrimaryMetrics = "R2Score" + ForecastingPrimaryMetricsSpearmanCorrelation ForecastingPrimaryMetrics = "SpearmanCorrelation" +) + +func PossibleValuesForForecastingPrimaryMetrics() []string { + return []string{ + string(ForecastingPrimaryMetricsNormalizedMeanAbsoluteError), + string(ForecastingPrimaryMetricsNormalizedRootMeanSquaredError), + string(ForecastingPrimaryMetricsRTwoScore), + string(ForecastingPrimaryMetricsSpearmanCorrelation), + } +} + +func (s *ForecastingPrimaryMetrics) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseForecastingPrimaryMetrics(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseForecastingPrimaryMetrics(input string) (*ForecastingPrimaryMetrics, error) { + vals := map[string]ForecastingPrimaryMetrics{ + "normalizedmeanabsoluteerror": ForecastingPrimaryMetricsNormalizedMeanAbsoluteError, + "normalizedrootmeansquarederror": ForecastingPrimaryMetricsNormalizedRootMeanSquaredError, + "r2score": ForecastingPrimaryMetricsRTwoScore, + "spearmancorrelation": ForecastingPrimaryMetricsSpearmanCorrelation, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ForecastingPrimaryMetrics(input) + return &out, nil +} + +type Goal string + +const ( + GoalMaximize Goal = "Maximize" + GoalMinimize Goal = "Minimize" +) + +func PossibleValuesForGoal() []string { + return []string{ + string(GoalMaximize), + string(GoalMinimize), + } +} + +func (s *Goal) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseGoal(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseGoal(input string) (*Goal, error) { + vals := map[string]Goal{ + "maximize": GoalMaximize, + "minimize": GoalMinimize, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := Goal(input) + return &out, nil +} + +type IdentityConfigurationType string + +const ( + IdentityConfigurationTypeAMLToken IdentityConfigurationType = "AMLToken" + IdentityConfigurationTypeManaged IdentityConfigurationType = "Managed" + IdentityConfigurationTypeUserIdentity IdentityConfigurationType = "UserIdentity" +) + +func PossibleValuesForIdentityConfigurationType() []string { + return []string{ + string(IdentityConfigurationTypeAMLToken), + string(IdentityConfigurationTypeManaged), + string(IdentityConfigurationTypeUserIdentity), + } +} + +func (s *IdentityConfigurationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIdentityConfigurationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIdentityConfigurationType(input string) (*IdentityConfigurationType, error) { + vals := map[string]IdentityConfigurationType{ + "amltoken": IdentityConfigurationTypeAMLToken, + "managed": IdentityConfigurationTypeManaged, + "useridentity": IdentityConfigurationTypeUserIdentity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IdentityConfigurationType(input) + return &out, nil +} + +type InputDeliveryMode string + +const ( + InputDeliveryModeDirect InputDeliveryMode = "Direct" + InputDeliveryModeDownload InputDeliveryMode = "Download" + InputDeliveryModeEvalDownload InputDeliveryMode = "EvalDownload" + InputDeliveryModeEvalMount InputDeliveryMode = "EvalMount" + InputDeliveryModeReadOnlyMount InputDeliveryMode = "ReadOnlyMount" + InputDeliveryModeReadWriteMount InputDeliveryMode = "ReadWriteMount" +) + +func PossibleValuesForInputDeliveryMode() []string { + return []string{ + string(InputDeliveryModeDirect), + string(InputDeliveryModeDownload), + string(InputDeliveryModeEvalDownload), + string(InputDeliveryModeEvalMount), + string(InputDeliveryModeReadOnlyMount), + string(InputDeliveryModeReadWriteMount), + } +} + +func (s *InputDeliveryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInputDeliveryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInputDeliveryMode(input string) (*InputDeliveryMode, error) { + vals := map[string]InputDeliveryMode{ + "direct": InputDeliveryModeDirect, + "download": InputDeliveryModeDownload, + "evaldownload": InputDeliveryModeEvalDownload, + "evalmount": InputDeliveryModeEvalMount, + "readonlymount": InputDeliveryModeReadOnlyMount, + "readwritemount": InputDeliveryModeReadWriteMount, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InputDeliveryMode(input) + return &out, nil +} + +type InstanceSegmentationPrimaryMetrics string + +const ( + InstanceSegmentationPrimaryMetricsMeanAveragePrecision InstanceSegmentationPrimaryMetrics = "MeanAveragePrecision" +) + +func PossibleValuesForInstanceSegmentationPrimaryMetrics() []string { + return []string{ + string(InstanceSegmentationPrimaryMetricsMeanAveragePrecision), + } +} + +func (s *InstanceSegmentationPrimaryMetrics) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseInstanceSegmentationPrimaryMetrics(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseInstanceSegmentationPrimaryMetrics(input string) (*InstanceSegmentationPrimaryMetrics, error) { + vals := map[string]InstanceSegmentationPrimaryMetrics{ + "meanaverageprecision": InstanceSegmentationPrimaryMetricsMeanAveragePrecision, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := InstanceSegmentationPrimaryMetrics(input) + return &out, nil +} + +type JobInputType string + +const ( + JobInputTypeCustomModel JobInputType = "custom_model" + JobInputTypeLiteral JobInputType = "literal" + JobInputTypeMlflowModel JobInputType = "mlflow_model" + JobInputTypeMltable JobInputType = "mltable" + JobInputTypeTritonModel JobInputType = "triton_model" + JobInputTypeUriFile JobInputType = "uri_file" + JobInputTypeUriFolder JobInputType = "uri_folder" +) + +func PossibleValuesForJobInputType() []string { + return []string{ + string(JobInputTypeCustomModel), + string(JobInputTypeLiteral), + string(JobInputTypeMlflowModel), + string(JobInputTypeMltable), + string(JobInputTypeTritonModel), + string(JobInputTypeUriFile), + string(JobInputTypeUriFolder), + } +} + +func (s *JobInputType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseJobInputType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseJobInputType(input string) (*JobInputType, error) { + vals := map[string]JobInputType{ + "custom_model": JobInputTypeCustomModel, + "literal": JobInputTypeLiteral, + "mlflow_model": JobInputTypeMlflowModel, + "mltable": JobInputTypeMltable, + "triton_model": JobInputTypeTritonModel, + "uri_file": JobInputTypeUriFile, + "uri_folder": JobInputTypeUriFolder, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := JobInputType(input) + return &out, nil +} + +type JobLimitsType string + +const ( + JobLimitsTypeCommand JobLimitsType = "Command" + JobLimitsTypeSweep JobLimitsType = "Sweep" +) + +func PossibleValuesForJobLimitsType() []string { + return []string{ + string(JobLimitsTypeCommand), + string(JobLimitsTypeSweep), + } +} + +func (s *JobLimitsType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseJobLimitsType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseJobLimitsType(input string) (*JobLimitsType, error) { + vals := map[string]JobLimitsType{ + "command": JobLimitsTypeCommand, + "sweep": JobLimitsTypeSweep, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := JobLimitsType(input) + return &out, nil +} + +type JobOutputType string + +const ( + JobOutputTypeCustomModel JobOutputType = "custom_model" + JobOutputTypeMlflowModel JobOutputType = "mlflow_model" + JobOutputTypeMltable JobOutputType = "mltable" + JobOutputTypeTritonModel JobOutputType = "triton_model" + JobOutputTypeUriFile JobOutputType = "uri_file" + JobOutputTypeUriFolder JobOutputType = "uri_folder" +) + +func PossibleValuesForJobOutputType() []string { + return []string{ + string(JobOutputTypeCustomModel), + string(JobOutputTypeMlflowModel), + string(JobOutputTypeMltable), + string(JobOutputTypeTritonModel), + string(JobOutputTypeUriFile), + string(JobOutputTypeUriFolder), + } +} + +func (s *JobOutputType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseJobOutputType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseJobOutputType(input string) (*JobOutputType, error) { + vals := map[string]JobOutputType{ + "custom_model": JobOutputTypeCustomModel, + "mlflow_model": JobOutputTypeMlflowModel, + "mltable": JobOutputTypeMltable, + "triton_model": JobOutputTypeTritonModel, + "uri_file": JobOutputTypeUriFile, + "uri_folder": JobOutputTypeUriFolder, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := JobOutputType(input) + return &out, nil +} + +type JobStatus string + +const ( + JobStatusCancelRequested JobStatus = "CancelRequested" + JobStatusCanceled JobStatus = "Canceled" + JobStatusCompleted JobStatus = "Completed" + JobStatusFailed JobStatus = "Failed" + JobStatusFinalizing JobStatus = "Finalizing" + JobStatusNotResponding JobStatus = "NotResponding" + JobStatusNotStarted JobStatus = "NotStarted" + JobStatusPaused JobStatus = "Paused" + JobStatusPreparing JobStatus = "Preparing" + JobStatusProvisioning JobStatus = "Provisioning" + JobStatusQueued JobStatus = "Queued" + JobStatusRunning JobStatus = "Running" + JobStatusStarting JobStatus = "Starting" + JobStatusUnknown JobStatus = "Unknown" +) + +func PossibleValuesForJobStatus() []string { + return []string{ + string(JobStatusCancelRequested), + string(JobStatusCanceled), + string(JobStatusCompleted), + string(JobStatusFailed), + string(JobStatusFinalizing), + string(JobStatusNotResponding), + string(JobStatusNotStarted), + string(JobStatusPaused), + string(JobStatusPreparing), + string(JobStatusProvisioning), + string(JobStatusQueued), + string(JobStatusRunning), + string(JobStatusStarting), + string(JobStatusUnknown), + } +} + +func (s *JobStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseJobStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseJobStatus(input string) (*JobStatus, error) { + vals := map[string]JobStatus{ + "cancelrequested": JobStatusCancelRequested, + "canceled": JobStatusCanceled, + "completed": JobStatusCompleted, + "failed": JobStatusFailed, + "finalizing": JobStatusFinalizing, + "notresponding": JobStatusNotResponding, + "notstarted": JobStatusNotStarted, + "paused": JobStatusPaused, + "preparing": JobStatusPreparing, + "provisioning": JobStatusProvisioning, + "queued": JobStatusQueued, + "running": JobStatusRunning, + "starting": JobStatusStarting, + "unknown": JobStatusUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := JobStatus(input) + return &out, nil +} + +type JobTier string + +const ( + JobTierBasic JobTier = "Basic" + JobTierNull JobTier = "Null" + JobTierPremium JobTier = "Premium" + JobTierSpot JobTier = "Spot" + JobTierStandard JobTier = "Standard" +) + +func PossibleValuesForJobTier() []string { + return []string{ + string(JobTierBasic), + string(JobTierNull), + string(JobTierPremium), + string(JobTierSpot), + string(JobTierStandard), + } +} + +func (s *JobTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseJobTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseJobTier(input string) (*JobTier, error) { + vals := map[string]JobTier{ + "basic": JobTierBasic, + "null": JobTierNull, + "premium": JobTierPremium, + "spot": JobTierSpot, + "standard": JobTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := JobTier(input) + return &out, nil +} + +type JobType string + +const ( + JobTypeAutoML JobType = "AutoML" + JobTypeCommand JobType = "Command" + JobTypePipeline JobType = "Pipeline" + JobTypeSpark JobType = "Spark" + JobTypeSweep JobType = "Sweep" +) + +func PossibleValuesForJobType() []string { + return []string{ + string(JobTypeAutoML), + string(JobTypeCommand), + string(JobTypePipeline), + string(JobTypeSpark), + string(JobTypeSweep), + } +} + +func (s *JobType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseJobType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseJobType(input string) (*JobType, error) { + vals := map[string]JobType{ + "automl": JobTypeAutoML, + "command": JobTypeCommand, + "pipeline": JobTypePipeline, + "spark": JobTypeSpark, + "sweep": JobTypeSweep, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := JobType(input) + return &out, nil +} + +type LearningRateScheduler string + +const ( + LearningRateSchedulerNone LearningRateScheduler = "None" + LearningRateSchedulerStep LearningRateScheduler = "Step" + LearningRateSchedulerWarmupCosine LearningRateScheduler = "WarmupCosine" +) + +func PossibleValuesForLearningRateScheduler() []string { + return []string{ + string(LearningRateSchedulerNone), + string(LearningRateSchedulerStep), + string(LearningRateSchedulerWarmupCosine), + } +} + +func (s *LearningRateScheduler) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLearningRateScheduler(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLearningRateScheduler(input string) (*LearningRateScheduler, error) { + vals := map[string]LearningRateScheduler{ + "none": LearningRateSchedulerNone, + "step": LearningRateSchedulerStep, + "warmupcosine": LearningRateSchedulerWarmupCosine, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LearningRateScheduler(input) + return &out, nil +} + +type LogVerbosity string + +const ( + LogVerbosityCritical LogVerbosity = "Critical" + LogVerbosityDebug LogVerbosity = "Debug" + LogVerbosityError LogVerbosity = "Error" + LogVerbosityInfo LogVerbosity = "Info" + LogVerbosityNotSet LogVerbosity = "NotSet" + LogVerbosityWarning LogVerbosity = "Warning" +) + +func PossibleValuesForLogVerbosity() []string { + return []string{ + string(LogVerbosityCritical), + string(LogVerbosityDebug), + string(LogVerbosityError), + string(LogVerbosityInfo), + string(LogVerbosityNotSet), + string(LogVerbosityWarning), + } +} + +func (s *LogVerbosity) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseLogVerbosity(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseLogVerbosity(input string) (*LogVerbosity, error) { + vals := map[string]LogVerbosity{ + "critical": LogVerbosityCritical, + "debug": LogVerbosityDebug, + "error": LogVerbosityError, + "info": LogVerbosityInfo, + "notset": LogVerbosityNotSet, + "warning": LogVerbosityWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := LogVerbosity(input) + return &out, nil +} + +type ModelSize string + +const ( + ModelSizeExtraLarge ModelSize = "ExtraLarge" + ModelSizeLarge ModelSize = "Large" + ModelSizeMedium ModelSize = "Medium" + ModelSizeNone ModelSize = "None" + ModelSizeSmall ModelSize = "Small" +) + +func PossibleValuesForModelSize() []string { + return []string{ + string(ModelSizeExtraLarge), + string(ModelSizeLarge), + string(ModelSizeMedium), + string(ModelSizeNone), + string(ModelSizeSmall), + } +} + +func (s *ModelSize) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseModelSize(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseModelSize(input string) (*ModelSize, error) { + vals := map[string]ModelSize{ + "extralarge": ModelSizeExtraLarge, + "large": ModelSizeLarge, + "medium": ModelSizeMedium, + "none": ModelSizeNone, + "small": ModelSizeSmall, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ModelSize(input) + return &out, nil +} + +type ModelTaskType string + +const ( + ModelTaskTypeClassification ModelTaskType = "Classification" + ModelTaskTypeRegression ModelTaskType = "Regression" +) + +func PossibleValuesForModelTaskType() []string { + return []string{ + string(ModelTaskTypeClassification), + string(ModelTaskTypeRegression), + } +} + +func (s *ModelTaskType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseModelTaskType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseModelTaskType(input string) (*ModelTaskType, error) { + vals := map[string]ModelTaskType{ + "classification": ModelTaskTypeClassification, + "regression": ModelTaskTypeRegression, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ModelTaskType(input) + return &out, nil +} + +type MonitorComputeIdentityType string + +const ( + MonitorComputeIdentityTypeAmlToken MonitorComputeIdentityType = "AmlToken" + MonitorComputeIdentityTypeManagedIdentity MonitorComputeIdentityType = "ManagedIdentity" +) + +func PossibleValuesForMonitorComputeIdentityType() []string { + return []string{ + string(MonitorComputeIdentityTypeAmlToken), + string(MonitorComputeIdentityTypeManagedIdentity), + } +} + +func (s *MonitorComputeIdentityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMonitorComputeIdentityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMonitorComputeIdentityType(input string) (*MonitorComputeIdentityType, error) { + vals := map[string]MonitorComputeIdentityType{ + "amltoken": MonitorComputeIdentityTypeAmlToken, + "managedidentity": MonitorComputeIdentityTypeManagedIdentity, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MonitorComputeIdentityType(input) + return &out, nil +} + +type MonitorComputeType string + +const ( + MonitorComputeTypeServerlessSpark MonitorComputeType = "ServerlessSpark" +) + +func PossibleValuesForMonitorComputeType() []string { + return []string{ + string(MonitorComputeTypeServerlessSpark), + } +} + +func (s *MonitorComputeType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMonitorComputeType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMonitorComputeType(input string) (*MonitorComputeType, error) { + vals := map[string]MonitorComputeType{ + "serverlessspark": MonitorComputeTypeServerlessSpark, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MonitorComputeType(input) + return &out, nil +} + +type MonitoringFeatureDataType string + +const ( + MonitoringFeatureDataTypeCategorical MonitoringFeatureDataType = "Categorical" + MonitoringFeatureDataTypeNumerical MonitoringFeatureDataType = "Numerical" +) + +func PossibleValuesForMonitoringFeatureDataType() []string { + return []string{ + string(MonitoringFeatureDataTypeCategorical), + string(MonitoringFeatureDataTypeNumerical), + } +} + +func (s *MonitoringFeatureDataType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMonitoringFeatureDataType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMonitoringFeatureDataType(input string) (*MonitoringFeatureDataType, error) { + vals := map[string]MonitoringFeatureDataType{ + "categorical": MonitoringFeatureDataTypeCategorical, + "numerical": MonitoringFeatureDataTypeNumerical, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MonitoringFeatureDataType(input) + return &out, nil +} + +type MonitoringFeatureFilterType string + +const ( + MonitoringFeatureFilterTypeAllFeatures MonitoringFeatureFilterType = "AllFeatures" + MonitoringFeatureFilterTypeFeatureSubset MonitoringFeatureFilterType = "FeatureSubset" + MonitoringFeatureFilterTypeTopNByAttribution MonitoringFeatureFilterType = "TopNByAttribution" +) + +func PossibleValuesForMonitoringFeatureFilterType() []string { + return []string{ + string(MonitoringFeatureFilterTypeAllFeatures), + string(MonitoringFeatureFilterTypeFeatureSubset), + string(MonitoringFeatureFilterTypeTopNByAttribution), + } +} + +func (s *MonitoringFeatureFilterType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMonitoringFeatureFilterType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMonitoringFeatureFilterType(input string) (*MonitoringFeatureFilterType, error) { + vals := map[string]MonitoringFeatureFilterType{ + "allfeatures": MonitoringFeatureFilterTypeAllFeatures, + "featuresubset": MonitoringFeatureFilterTypeFeatureSubset, + "topnbyattribution": MonitoringFeatureFilterTypeTopNByAttribution, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MonitoringFeatureFilterType(input) + return &out, nil +} + +type MonitoringInputDataType string + +const ( + MonitoringInputDataTypeFixed MonitoringInputDataType = "Fixed" + MonitoringInputDataTypeRolling MonitoringInputDataType = "Rolling" + MonitoringInputDataTypeStatic MonitoringInputDataType = "Static" +) + +func PossibleValuesForMonitoringInputDataType() []string { + return []string{ + string(MonitoringInputDataTypeFixed), + string(MonitoringInputDataTypeRolling), + string(MonitoringInputDataTypeStatic), + } +} + +func (s *MonitoringInputDataType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMonitoringInputDataType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMonitoringInputDataType(input string) (*MonitoringInputDataType, error) { + vals := map[string]MonitoringInputDataType{ + "fixed": MonitoringInputDataTypeFixed, + "rolling": MonitoringInputDataTypeRolling, + "static": MonitoringInputDataTypeStatic, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MonitoringInputDataType(input) + return &out, nil +} + +type MonitoringNotificationType string + +const ( + MonitoringNotificationTypeAmlNotification MonitoringNotificationType = "AmlNotification" +) + +func PossibleValuesForMonitoringNotificationType() []string { + return []string{ + string(MonitoringNotificationTypeAmlNotification), + } +} + +func (s *MonitoringNotificationType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMonitoringNotificationType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMonitoringNotificationType(input string) (*MonitoringNotificationType, error) { + vals := map[string]MonitoringNotificationType{ + "amlnotification": MonitoringNotificationTypeAmlNotification, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MonitoringNotificationType(input) + return &out, nil +} + +type MonitoringSignalType string + +const ( + MonitoringSignalTypeCustom MonitoringSignalType = "Custom" + MonitoringSignalTypeDataDrift MonitoringSignalType = "DataDrift" + MonitoringSignalTypeDataQuality MonitoringSignalType = "DataQuality" + MonitoringSignalTypeFeatureAttributionDrift MonitoringSignalType = "FeatureAttributionDrift" + MonitoringSignalTypePredictionDrift MonitoringSignalType = "PredictionDrift" +) + +func PossibleValuesForMonitoringSignalType() []string { + return []string{ + string(MonitoringSignalTypeCustom), + string(MonitoringSignalTypeDataDrift), + string(MonitoringSignalTypeDataQuality), + string(MonitoringSignalTypeFeatureAttributionDrift), + string(MonitoringSignalTypePredictionDrift), + } +} + +func (s *MonitoringSignalType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseMonitoringSignalType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseMonitoringSignalType(input string) (*MonitoringSignalType, error) { + vals := map[string]MonitoringSignalType{ + "custom": MonitoringSignalTypeCustom, + "datadrift": MonitoringSignalTypeDataDrift, + "dataquality": MonitoringSignalTypeDataQuality, + "featureattributiondrift": MonitoringSignalTypeFeatureAttributionDrift, + "predictiondrift": MonitoringSignalTypePredictionDrift, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := MonitoringSignalType(input) + return &out, nil +} + +type NCrossValidationsMode string + +const ( + NCrossValidationsModeAuto NCrossValidationsMode = "Auto" + NCrossValidationsModeCustom NCrossValidationsMode = "Custom" +) + +func PossibleValuesForNCrossValidationsMode() []string { + return []string{ + string(NCrossValidationsModeAuto), + string(NCrossValidationsModeCustom), + } +} + +func (s *NCrossValidationsMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNCrossValidationsMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNCrossValidationsMode(input string) (*NCrossValidationsMode, error) { + vals := map[string]NCrossValidationsMode{ + "auto": NCrossValidationsModeAuto, + "custom": NCrossValidationsModeCustom, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NCrossValidationsMode(input) + return &out, nil +} + +type NodesValueType string + +const ( + NodesValueTypeAll NodesValueType = "All" +) + +func PossibleValuesForNodesValueType() []string { + return []string{ + string(NodesValueTypeAll), + } +} + +func (s *NodesValueType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNodesValueType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNodesValueType(input string) (*NodesValueType, error) { + vals := map[string]NodesValueType{ + "all": NodesValueTypeAll, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NodesValueType(input) + return &out, nil +} + +type NumericalDataDriftMetric string + +const ( + NumericalDataDriftMetricJensenShannonDistance NumericalDataDriftMetric = "JensenShannonDistance" + NumericalDataDriftMetricNormalizedWassersteinDistance NumericalDataDriftMetric = "NormalizedWassersteinDistance" + NumericalDataDriftMetricPopulationStabilityIndex NumericalDataDriftMetric = "PopulationStabilityIndex" + NumericalDataDriftMetricTwoSampleKolmogorovSmirnovTest NumericalDataDriftMetric = "TwoSampleKolmogorovSmirnovTest" +) + +func PossibleValuesForNumericalDataDriftMetric() []string { + return []string{ + string(NumericalDataDriftMetricJensenShannonDistance), + string(NumericalDataDriftMetricNormalizedWassersteinDistance), + string(NumericalDataDriftMetricPopulationStabilityIndex), + string(NumericalDataDriftMetricTwoSampleKolmogorovSmirnovTest), + } +} + +func (s *NumericalDataDriftMetric) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNumericalDataDriftMetric(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNumericalDataDriftMetric(input string) (*NumericalDataDriftMetric, error) { + vals := map[string]NumericalDataDriftMetric{ + "jensenshannondistance": NumericalDataDriftMetricJensenShannonDistance, + "normalizedwassersteindistance": NumericalDataDriftMetricNormalizedWassersteinDistance, + "populationstabilityindex": NumericalDataDriftMetricPopulationStabilityIndex, + "twosamplekolmogorovsmirnovtest": NumericalDataDriftMetricTwoSampleKolmogorovSmirnovTest, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NumericalDataDriftMetric(input) + return &out, nil +} + +type NumericalDataQualityMetric string + +const ( + NumericalDataQualityMetricDataTypeErrorRate NumericalDataQualityMetric = "DataTypeErrorRate" + NumericalDataQualityMetricNullValueRate NumericalDataQualityMetric = "NullValueRate" + NumericalDataQualityMetricOutOfBoundsRate NumericalDataQualityMetric = "OutOfBoundsRate" +) + +func PossibleValuesForNumericalDataQualityMetric() []string { + return []string{ + string(NumericalDataQualityMetricDataTypeErrorRate), + string(NumericalDataQualityMetricNullValueRate), + string(NumericalDataQualityMetricOutOfBoundsRate), + } +} + +func (s *NumericalDataQualityMetric) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNumericalDataQualityMetric(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNumericalDataQualityMetric(input string) (*NumericalDataQualityMetric, error) { + vals := map[string]NumericalDataQualityMetric{ + "datatypeerrorrate": NumericalDataQualityMetricDataTypeErrorRate, + "nullvaluerate": NumericalDataQualityMetricNullValueRate, + "outofboundsrate": NumericalDataQualityMetricOutOfBoundsRate, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NumericalDataQualityMetric(input) + return &out, nil +} + +type NumericalPredictionDriftMetric string + +const ( + NumericalPredictionDriftMetricJensenShannonDistance NumericalPredictionDriftMetric = "JensenShannonDistance" + NumericalPredictionDriftMetricNormalizedWassersteinDistance NumericalPredictionDriftMetric = "NormalizedWassersteinDistance" + NumericalPredictionDriftMetricPopulationStabilityIndex NumericalPredictionDriftMetric = "PopulationStabilityIndex" + NumericalPredictionDriftMetricTwoSampleKolmogorovSmirnovTest NumericalPredictionDriftMetric = "TwoSampleKolmogorovSmirnovTest" +) + +func PossibleValuesForNumericalPredictionDriftMetric() []string { + return []string{ + string(NumericalPredictionDriftMetricJensenShannonDistance), + string(NumericalPredictionDriftMetricNormalizedWassersteinDistance), + string(NumericalPredictionDriftMetricPopulationStabilityIndex), + string(NumericalPredictionDriftMetricTwoSampleKolmogorovSmirnovTest), + } +} + +func (s *NumericalPredictionDriftMetric) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseNumericalPredictionDriftMetric(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseNumericalPredictionDriftMetric(input string) (*NumericalPredictionDriftMetric, error) { + vals := map[string]NumericalPredictionDriftMetric{ + "jensenshannondistance": NumericalPredictionDriftMetricJensenShannonDistance, + "normalizedwassersteindistance": NumericalPredictionDriftMetricNormalizedWassersteinDistance, + "populationstabilityindex": NumericalPredictionDriftMetricPopulationStabilityIndex, + "twosamplekolmogorovsmirnovtest": NumericalPredictionDriftMetricTwoSampleKolmogorovSmirnovTest, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := NumericalPredictionDriftMetric(input) + return &out, nil +} + +type ObjectDetectionPrimaryMetrics string + +const ( + ObjectDetectionPrimaryMetricsMeanAveragePrecision ObjectDetectionPrimaryMetrics = "MeanAveragePrecision" +) + +func PossibleValuesForObjectDetectionPrimaryMetrics() []string { + return []string{ + string(ObjectDetectionPrimaryMetricsMeanAveragePrecision), + } +} + +func (s *ObjectDetectionPrimaryMetrics) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseObjectDetectionPrimaryMetrics(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseObjectDetectionPrimaryMetrics(input string) (*ObjectDetectionPrimaryMetrics, error) { + vals := map[string]ObjectDetectionPrimaryMetrics{ + "meanaverageprecision": ObjectDetectionPrimaryMetricsMeanAveragePrecision, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ObjectDetectionPrimaryMetrics(input) + return &out, nil +} + +type OutputDeliveryMode string + +const ( + OutputDeliveryModeDirect OutputDeliveryMode = "Direct" + OutputDeliveryModeReadWriteMount OutputDeliveryMode = "ReadWriteMount" + OutputDeliveryModeUpload OutputDeliveryMode = "Upload" +) + +func PossibleValuesForOutputDeliveryMode() []string { + return []string{ + string(OutputDeliveryModeDirect), + string(OutputDeliveryModeReadWriteMount), + string(OutputDeliveryModeUpload), + } +} + +func (s *OutputDeliveryMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseOutputDeliveryMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseOutputDeliveryMode(input string) (*OutputDeliveryMode, error) { + vals := map[string]OutputDeliveryMode{ + "direct": OutputDeliveryModeDirect, + "readwritemount": OutputDeliveryModeReadWriteMount, + "upload": OutputDeliveryModeUpload, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := OutputDeliveryMode(input) + return &out, nil +} + +type RandomSamplingAlgorithmRule string + +const ( + RandomSamplingAlgorithmRuleRandom RandomSamplingAlgorithmRule = "Random" + RandomSamplingAlgorithmRuleSobol RandomSamplingAlgorithmRule = "Sobol" +) + +func PossibleValuesForRandomSamplingAlgorithmRule() []string { + return []string{ + string(RandomSamplingAlgorithmRuleRandom), + string(RandomSamplingAlgorithmRuleSobol), + } +} + +func (s *RandomSamplingAlgorithmRule) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRandomSamplingAlgorithmRule(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRandomSamplingAlgorithmRule(input string) (*RandomSamplingAlgorithmRule, error) { + vals := map[string]RandomSamplingAlgorithmRule{ + "random": RandomSamplingAlgorithmRuleRandom, + "sobol": RandomSamplingAlgorithmRuleSobol, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RandomSamplingAlgorithmRule(input) + return &out, nil +} + +type RecurrenceFrequency string + +const ( + RecurrenceFrequencyDay RecurrenceFrequency = "Day" + RecurrenceFrequencyHour RecurrenceFrequency = "Hour" + RecurrenceFrequencyMinute RecurrenceFrequency = "Minute" + RecurrenceFrequencyMonth RecurrenceFrequency = "Month" + RecurrenceFrequencyWeek RecurrenceFrequency = "Week" +) + +func PossibleValuesForRecurrenceFrequency() []string { + return []string{ + string(RecurrenceFrequencyDay), + string(RecurrenceFrequencyHour), + string(RecurrenceFrequencyMinute), + string(RecurrenceFrequencyMonth), + string(RecurrenceFrequencyWeek), + } +} + +func (s *RecurrenceFrequency) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRecurrenceFrequency(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRecurrenceFrequency(input string) (*RecurrenceFrequency, error) { + vals := map[string]RecurrenceFrequency{ + "day": RecurrenceFrequencyDay, + "hour": RecurrenceFrequencyHour, + "minute": RecurrenceFrequencyMinute, + "month": RecurrenceFrequencyMonth, + "week": RecurrenceFrequencyWeek, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RecurrenceFrequency(input) + return &out, nil +} + +type RegressionModels string + +const ( + RegressionModelsDecisionTree RegressionModels = "DecisionTree" + RegressionModelsElasticNet RegressionModels = "ElasticNet" + RegressionModelsExtremeRandomTrees RegressionModels = "ExtremeRandomTrees" + RegressionModelsGradientBoosting RegressionModels = "GradientBoosting" + RegressionModelsKNN RegressionModels = "KNN" + RegressionModelsLassoLars RegressionModels = "LassoLars" + RegressionModelsLightGBM RegressionModels = "LightGBM" + RegressionModelsRandomForest RegressionModels = "RandomForest" + RegressionModelsSGD RegressionModels = "SGD" + RegressionModelsXGBoostRegressor RegressionModels = "XGBoostRegressor" +) + +func PossibleValuesForRegressionModels() []string { + return []string{ + string(RegressionModelsDecisionTree), + string(RegressionModelsElasticNet), + string(RegressionModelsExtremeRandomTrees), + string(RegressionModelsGradientBoosting), + string(RegressionModelsKNN), + string(RegressionModelsLassoLars), + string(RegressionModelsLightGBM), + string(RegressionModelsRandomForest), + string(RegressionModelsSGD), + string(RegressionModelsXGBoostRegressor), + } +} + +func (s *RegressionModels) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRegressionModels(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRegressionModels(input string) (*RegressionModels, error) { + vals := map[string]RegressionModels{ + "decisiontree": RegressionModelsDecisionTree, + "elasticnet": RegressionModelsElasticNet, + "extremerandomtrees": RegressionModelsExtremeRandomTrees, + "gradientboosting": RegressionModelsGradientBoosting, + "knn": RegressionModelsKNN, + "lassolars": RegressionModelsLassoLars, + "lightgbm": RegressionModelsLightGBM, + "randomforest": RegressionModelsRandomForest, + "sgd": RegressionModelsSGD, + "xgboostregressor": RegressionModelsXGBoostRegressor, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RegressionModels(input) + return &out, nil +} + +type RegressionPrimaryMetrics string + +const ( + RegressionPrimaryMetricsNormalizedMeanAbsoluteError RegressionPrimaryMetrics = "NormalizedMeanAbsoluteError" + RegressionPrimaryMetricsNormalizedRootMeanSquaredError RegressionPrimaryMetrics = "NormalizedRootMeanSquaredError" + RegressionPrimaryMetricsRTwoScore RegressionPrimaryMetrics = "R2Score" + RegressionPrimaryMetricsSpearmanCorrelation RegressionPrimaryMetrics = "SpearmanCorrelation" +) + +func PossibleValuesForRegressionPrimaryMetrics() []string { + return []string{ + string(RegressionPrimaryMetricsNormalizedMeanAbsoluteError), + string(RegressionPrimaryMetricsNormalizedRootMeanSquaredError), + string(RegressionPrimaryMetricsRTwoScore), + string(RegressionPrimaryMetricsSpearmanCorrelation), + } +} + +func (s *RegressionPrimaryMetrics) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRegressionPrimaryMetrics(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRegressionPrimaryMetrics(input string) (*RegressionPrimaryMetrics, error) { + vals := map[string]RegressionPrimaryMetrics{ + "normalizedmeanabsoluteerror": RegressionPrimaryMetricsNormalizedMeanAbsoluteError, + "normalizedrootmeansquarederror": RegressionPrimaryMetricsNormalizedRootMeanSquaredError, + "r2score": RegressionPrimaryMetricsRTwoScore, + "spearmancorrelation": RegressionPrimaryMetricsSpearmanCorrelation, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RegressionPrimaryMetrics(input) + return &out, nil +} + +type SamplingAlgorithmType string + +const ( + SamplingAlgorithmTypeBayesian SamplingAlgorithmType = "Bayesian" + SamplingAlgorithmTypeGrid SamplingAlgorithmType = "Grid" + SamplingAlgorithmTypeRandom SamplingAlgorithmType = "Random" +) + +func PossibleValuesForSamplingAlgorithmType() []string { + return []string{ + string(SamplingAlgorithmTypeBayesian), + string(SamplingAlgorithmTypeGrid), + string(SamplingAlgorithmTypeRandom), + } +} + +func (s *SamplingAlgorithmType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSamplingAlgorithmType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSamplingAlgorithmType(input string) (*SamplingAlgorithmType, error) { + vals := map[string]SamplingAlgorithmType{ + "bayesian": SamplingAlgorithmTypeBayesian, + "grid": SamplingAlgorithmTypeGrid, + "random": SamplingAlgorithmTypeRandom, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SamplingAlgorithmType(input) + return &out, nil +} + +type ScheduleActionType string + +const ( + ScheduleActionTypeCreateJob ScheduleActionType = "CreateJob" + ScheduleActionTypeCreateMonitor ScheduleActionType = "CreateMonitor" + ScheduleActionTypeInvokeBatchEndpoint ScheduleActionType = "InvokeBatchEndpoint" +) + +func PossibleValuesForScheduleActionType() []string { + return []string{ + string(ScheduleActionTypeCreateJob), + string(ScheduleActionTypeCreateMonitor), + string(ScheduleActionTypeInvokeBatchEndpoint), + } +} + +func (s *ScheduleActionType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScheduleActionType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScheduleActionType(input string) (*ScheduleActionType, error) { + vals := map[string]ScheduleActionType{ + "createjob": ScheduleActionTypeCreateJob, + "createmonitor": ScheduleActionTypeCreateMonitor, + "invokebatchendpoint": ScheduleActionTypeInvokeBatchEndpoint, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScheduleActionType(input) + return &out, nil +} + +type ScheduleListViewType string + +const ( + ScheduleListViewTypeAll ScheduleListViewType = "All" + ScheduleListViewTypeDisabledOnly ScheduleListViewType = "DisabledOnly" + ScheduleListViewTypeEnabledOnly ScheduleListViewType = "EnabledOnly" +) + +func PossibleValuesForScheduleListViewType() []string { + return []string{ + string(ScheduleListViewTypeAll), + string(ScheduleListViewTypeDisabledOnly), + string(ScheduleListViewTypeEnabledOnly), + } +} + +func (s *ScheduleListViewType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScheduleListViewType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScheduleListViewType(input string) (*ScheduleListViewType, error) { + vals := map[string]ScheduleListViewType{ + "all": ScheduleListViewTypeAll, + "disabledonly": ScheduleListViewTypeDisabledOnly, + "enabledonly": ScheduleListViewTypeEnabledOnly, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScheduleListViewType(input) + return &out, nil +} + +type ScheduleProvisioningStatus string + +const ( + ScheduleProvisioningStatusCanceled ScheduleProvisioningStatus = "Canceled" + ScheduleProvisioningStatusCreating ScheduleProvisioningStatus = "Creating" + ScheduleProvisioningStatusDeleting ScheduleProvisioningStatus = "Deleting" + ScheduleProvisioningStatusFailed ScheduleProvisioningStatus = "Failed" + ScheduleProvisioningStatusSucceeded ScheduleProvisioningStatus = "Succeeded" + ScheduleProvisioningStatusUpdating ScheduleProvisioningStatus = "Updating" +) + +func PossibleValuesForScheduleProvisioningStatus() []string { + return []string{ + string(ScheduleProvisioningStatusCanceled), + string(ScheduleProvisioningStatusCreating), + string(ScheduleProvisioningStatusDeleting), + string(ScheduleProvisioningStatusFailed), + string(ScheduleProvisioningStatusSucceeded), + string(ScheduleProvisioningStatusUpdating), + } +} + +func (s *ScheduleProvisioningStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseScheduleProvisioningStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseScheduleProvisioningStatus(input string) (*ScheduleProvisioningStatus, error) { + vals := map[string]ScheduleProvisioningStatus{ + "canceled": ScheduleProvisioningStatusCanceled, + "creating": ScheduleProvisioningStatusCreating, + "deleting": ScheduleProvisioningStatusDeleting, + "failed": ScheduleProvisioningStatusFailed, + "succeeded": ScheduleProvisioningStatusSucceeded, + "updating": ScheduleProvisioningStatusUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ScheduleProvisioningStatus(input) + return &out, nil +} + +type SeasonalityMode string + +const ( + SeasonalityModeAuto SeasonalityMode = "Auto" + SeasonalityModeCustom SeasonalityMode = "Custom" +) + +func PossibleValuesForSeasonalityMode() []string { + return []string{ + string(SeasonalityModeAuto), + string(SeasonalityModeCustom), + } +} + +func (s *SeasonalityMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSeasonalityMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSeasonalityMode(input string) (*SeasonalityMode, error) { + vals := map[string]SeasonalityMode{ + "auto": SeasonalityModeAuto, + "custom": SeasonalityModeCustom, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SeasonalityMode(input) + return &out, nil +} + +type ShortSeriesHandlingConfiguration string + +const ( + ShortSeriesHandlingConfigurationAuto ShortSeriesHandlingConfiguration = "Auto" + ShortSeriesHandlingConfigurationDrop ShortSeriesHandlingConfiguration = "Drop" + ShortSeriesHandlingConfigurationNone ShortSeriesHandlingConfiguration = "None" + ShortSeriesHandlingConfigurationPad ShortSeriesHandlingConfiguration = "Pad" +) + +func PossibleValuesForShortSeriesHandlingConfiguration() []string { + return []string{ + string(ShortSeriesHandlingConfigurationAuto), + string(ShortSeriesHandlingConfigurationDrop), + string(ShortSeriesHandlingConfigurationNone), + string(ShortSeriesHandlingConfigurationPad), + } +} + +func (s *ShortSeriesHandlingConfiguration) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseShortSeriesHandlingConfiguration(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseShortSeriesHandlingConfiguration(input string) (*ShortSeriesHandlingConfiguration, error) { + vals := map[string]ShortSeriesHandlingConfiguration{ + "auto": ShortSeriesHandlingConfigurationAuto, + "drop": ShortSeriesHandlingConfigurationDrop, + "none": ShortSeriesHandlingConfigurationNone, + "pad": ShortSeriesHandlingConfigurationPad, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ShortSeriesHandlingConfiguration(input) + return &out, nil +} + +type SparkJobEntryType string + +const ( + SparkJobEntryTypeSparkJobPythonEntry SparkJobEntryType = "SparkJobPythonEntry" + SparkJobEntryTypeSparkJobScalaEntry SparkJobEntryType = "SparkJobScalaEntry" +) + +func PossibleValuesForSparkJobEntryType() []string { + return []string{ + string(SparkJobEntryTypeSparkJobPythonEntry), + string(SparkJobEntryTypeSparkJobScalaEntry), + } +} + +func (s *SparkJobEntryType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSparkJobEntryType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSparkJobEntryType(input string) (*SparkJobEntryType, error) { + vals := map[string]SparkJobEntryType{ + "sparkjobpythonentry": SparkJobEntryTypeSparkJobPythonEntry, + "sparkjobscalaentry": SparkJobEntryTypeSparkJobScalaEntry, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SparkJobEntryType(input) + return &out, nil +} + +type StackMetaLearnerType string + +const ( + StackMetaLearnerTypeElasticNet StackMetaLearnerType = "ElasticNet" + StackMetaLearnerTypeElasticNetCV StackMetaLearnerType = "ElasticNetCV" + StackMetaLearnerTypeLightGBMClassifier StackMetaLearnerType = "LightGBMClassifier" + StackMetaLearnerTypeLightGBMRegressor StackMetaLearnerType = "LightGBMRegressor" + StackMetaLearnerTypeLinearRegression StackMetaLearnerType = "LinearRegression" + StackMetaLearnerTypeLogisticRegression StackMetaLearnerType = "LogisticRegression" + StackMetaLearnerTypeLogisticRegressionCV StackMetaLearnerType = "LogisticRegressionCV" + StackMetaLearnerTypeNone StackMetaLearnerType = "None" +) + +func PossibleValuesForStackMetaLearnerType() []string { + return []string{ + string(StackMetaLearnerTypeElasticNet), + string(StackMetaLearnerTypeElasticNetCV), + string(StackMetaLearnerTypeLightGBMClassifier), + string(StackMetaLearnerTypeLightGBMRegressor), + string(StackMetaLearnerTypeLinearRegression), + string(StackMetaLearnerTypeLogisticRegression), + string(StackMetaLearnerTypeLogisticRegressionCV), + string(StackMetaLearnerTypeNone), + } +} + +func (s *StackMetaLearnerType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStackMetaLearnerType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStackMetaLearnerType(input string) (*StackMetaLearnerType, error) { + vals := map[string]StackMetaLearnerType{ + "elasticnet": StackMetaLearnerTypeElasticNet, + "elasticnetcv": StackMetaLearnerTypeElasticNetCV, + "lightgbmclassifier": StackMetaLearnerTypeLightGBMClassifier, + "lightgbmregressor": StackMetaLearnerTypeLightGBMRegressor, + "linearregression": StackMetaLearnerTypeLinearRegression, + "logisticregression": StackMetaLearnerTypeLogisticRegression, + "logisticregressioncv": StackMetaLearnerTypeLogisticRegressionCV, + "none": StackMetaLearnerTypeNone, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StackMetaLearnerType(input) + return &out, nil +} + +type StochasticOptimizer string + +const ( + StochasticOptimizerAdam StochasticOptimizer = "Adam" + StochasticOptimizerAdamw StochasticOptimizer = "Adamw" + StochasticOptimizerNone StochasticOptimizer = "None" + StochasticOptimizerSgd StochasticOptimizer = "Sgd" +) + +func PossibleValuesForStochasticOptimizer() []string { + return []string{ + string(StochasticOptimizerAdam), + string(StochasticOptimizerAdamw), + string(StochasticOptimizerNone), + string(StochasticOptimizerSgd), + } +} + +func (s *StochasticOptimizer) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseStochasticOptimizer(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseStochasticOptimizer(input string) (*StochasticOptimizer, error) { + vals := map[string]StochasticOptimizer{ + "adam": StochasticOptimizerAdam, + "adamw": StochasticOptimizerAdamw, + "none": StochasticOptimizerNone, + "sgd": StochasticOptimizerSgd, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := StochasticOptimizer(input) + return &out, nil +} + +type TargetAggregationFunction string + +const ( + TargetAggregationFunctionMax TargetAggregationFunction = "Max" + TargetAggregationFunctionMean TargetAggregationFunction = "Mean" + TargetAggregationFunctionMin TargetAggregationFunction = "Min" + TargetAggregationFunctionNone TargetAggregationFunction = "None" + TargetAggregationFunctionSum TargetAggregationFunction = "Sum" +) + +func PossibleValuesForTargetAggregationFunction() []string { + return []string{ + string(TargetAggregationFunctionMax), + string(TargetAggregationFunctionMean), + string(TargetAggregationFunctionMin), + string(TargetAggregationFunctionNone), + string(TargetAggregationFunctionSum), + } +} + +func (s *TargetAggregationFunction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTargetAggregationFunction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTargetAggregationFunction(input string) (*TargetAggregationFunction, error) { + vals := map[string]TargetAggregationFunction{ + "max": TargetAggregationFunctionMax, + "mean": TargetAggregationFunctionMean, + "min": TargetAggregationFunctionMin, + "none": TargetAggregationFunctionNone, + "sum": TargetAggregationFunctionSum, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TargetAggregationFunction(input) + return &out, nil +} + +type TargetLagsMode string + +const ( + TargetLagsModeAuto TargetLagsMode = "Auto" + TargetLagsModeCustom TargetLagsMode = "Custom" +) + +func PossibleValuesForTargetLagsMode() []string { + return []string{ + string(TargetLagsModeAuto), + string(TargetLagsModeCustom), + } +} + +func (s *TargetLagsMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTargetLagsMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTargetLagsMode(input string) (*TargetLagsMode, error) { + vals := map[string]TargetLagsMode{ + "auto": TargetLagsModeAuto, + "custom": TargetLagsModeCustom, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TargetLagsMode(input) + return &out, nil +} + +type TargetRollingWindowSizeMode string + +const ( + TargetRollingWindowSizeModeAuto TargetRollingWindowSizeMode = "Auto" + TargetRollingWindowSizeModeCustom TargetRollingWindowSizeMode = "Custom" +) + +func PossibleValuesForTargetRollingWindowSizeMode() []string { + return []string{ + string(TargetRollingWindowSizeModeAuto), + string(TargetRollingWindowSizeModeCustom), + } +} + +func (s *TargetRollingWindowSizeMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTargetRollingWindowSizeMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTargetRollingWindowSizeMode(input string) (*TargetRollingWindowSizeMode, error) { + vals := map[string]TargetRollingWindowSizeMode{ + "auto": TargetRollingWindowSizeModeAuto, + "custom": TargetRollingWindowSizeModeCustom, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TargetRollingWindowSizeMode(input) + return &out, nil +} + +type TaskType string + +const ( + TaskTypeClassification TaskType = "Classification" + TaskTypeForecasting TaskType = "Forecasting" + TaskTypeImageClassification TaskType = "ImageClassification" + TaskTypeImageClassificationMultilabel TaskType = "ImageClassificationMultilabel" + TaskTypeImageInstanceSegmentation TaskType = "ImageInstanceSegmentation" + TaskTypeImageObjectDetection TaskType = "ImageObjectDetection" + TaskTypeRegression TaskType = "Regression" + TaskTypeTextClassification TaskType = "TextClassification" + TaskTypeTextClassificationMultilabel TaskType = "TextClassificationMultilabel" + TaskTypeTextNER TaskType = "TextNER" +) + +func PossibleValuesForTaskType() []string { + return []string{ + string(TaskTypeClassification), + string(TaskTypeForecasting), + string(TaskTypeImageClassification), + string(TaskTypeImageClassificationMultilabel), + string(TaskTypeImageInstanceSegmentation), + string(TaskTypeImageObjectDetection), + string(TaskTypeRegression), + string(TaskTypeTextClassification), + string(TaskTypeTextClassificationMultilabel), + string(TaskTypeTextNER), + } +} + +func (s *TaskType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTaskType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTaskType(input string) (*TaskType, error) { + vals := map[string]TaskType{ + "classification": TaskTypeClassification, + "forecasting": TaskTypeForecasting, + "imageclassification": TaskTypeImageClassification, + "imageclassificationmultilabel": TaskTypeImageClassificationMultilabel, + "imageinstancesegmentation": TaskTypeImageInstanceSegmentation, + "imageobjectdetection": TaskTypeImageObjectDetection, + "regression": TaskTypeRegression, + "textclassification": TaskTypeTextClassification, + "textclassificationmultilabel": TaskTypeTextClassificationMultilabel, + "textner": TaskTypeTextNER, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TaskType(input) + return &out, nil +} + +type TriggerType string + +const ( + TriggerTypeCron TriggerType = "Cron" + TriggerTypeRecurrence TriggerType = "Recurrence" +) + +func PossibleValuesForTriggerType() []string { + return []string{ + string(TriggerTypeCron), + string(TriggerTypeRecurrence), + } +} + +func (s *TriggerType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseTriggerType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseTriggerType(input string) (*TriggerType, error) { + vals := map[string]TriggerType{ + "cron": TriggerTypeCron, + "recurrence": TriggerTypeRecurrence, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := TriggerType(input) + return &out, nil +} + +type UseStl string + +const ( + UseStlNone UseStl = "None" + UseStlSeason UseStl = "Season" + UseStlSeasonTrend UseStl = "SeasonTrend" +) + +func PossibleValuesForUseStl() []string { + return []string{ + string(UseStlNone), + string(UseStlSeason), + string(UseStlSeasonTrend), + } +} + +func (s *UseStl) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUseStl(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUseStl(input string) (*UseStl, error) { + vals := map[string]UseStl{ + "none": UseStlNone, + "season": UseStlSeason, + "seasontrend": UseStlSeasonTrend, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UseStl(input) + return &out, nil +} + +type ValidationMetricType string + +const ( + ValidationMetricTypeCoco ValidationMetricType = "Coco" + ValidationMetricTypeCocoVoc ValidationMetricType = "CocoVoc" + ValidationMetricTypeNone ValidationMetricType = "None" + ValidationMetricTypeVoc ValidationMetricType = "Voc" +) + +func PossibleValuesForValidationMetricType() []string { + return []string{ + string(ValidationMetricTypeCoco), + string(ValidationMetricTypeCocoVoc), + string(ValidationMetricTypeNone), + string(ValidationMetricTypeVoc), + } +} + +func (s *ValidationMetricType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseValidationMetricType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseValidationMetricType(input string) (*ValidationMetricType, error) { + vals := map[string]ValidationMetricType{ + "coco": ValidationMetricTypeCoco, + "cocovoc": ValidationMetricTypeCocoVoc, + "none": ValidationMetricTypeNone, + "voc": ValidationMetricTypeVoc, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ValidationMetricType(input) + return &out, nil +} + +type WebhookType string + +const ( + WebhookTypeAzureDevOps WebhookType = "AzureDevOps" +) + +func PossibleValuesForWebhookType() []string { + return []string{ + string(WebhookTypeAzureDevOps), + } +} + +func (s *WebhookType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseWebhookType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseWebhookType(input string) (*WebhookType, error) { + vals := map[string]WebhookType{ + "azuredevops": WebhookTypeAzureDevOps, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := WebhookType(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/machinelearningservices/2025-04-01/schedule/id_schedule.go b/resource-manager/machinelearningservices/2025-04-01/schedule/id_schedule.go new file mode 100644 index 00000000000..51f5110b9d5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/id_schedule.go @@ -0,0 +1,139 @@ +package schedule + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ScheduleId{}) +} + +var _ resourceids.ResourceId = &ScheduleId{} + +// ScheduleId is a struct representing the Resource ID for a Schedule +type ScheduleId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + ScheduleName string +} + +// NewScheduleID returns a new ScheduleId struct +func NewScheduleID(subscriptionId string, resourceGroupName string, workspaceName string, scheduleName string) ScheduleId { + return ScheduleId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + ScheduleName: scheduleName, + } +} + +// ParseScheduleID parses 'input' into a ScheduleId +func ParseScheduleID(input string) (*ScheduleId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScheduleId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScheduleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseScheduleIDInsensitively parses 'input' case-insensitively into a ScheduleId +// note: this method should only be used for API response data and not user input +func ParseScheduleIDInsensitively(input string) (*ScheduleId, error) { + parser := resourceids.NewParserFromResourceIdType(&ScheduleId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ScheduleId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ScheduleId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.ScheduleName, ok = input.Parsed["scheduleName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "scheduleName", input) + } + + return nil +} + +// ValidateScheduleID checks that 'input' can be parsed as a Schedule ID +func ValidateScheduleID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseScheduleID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Schedule ID +func (id ScheduleId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/schedules/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.ScheduleName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Schedule ID +func (id ScheduleId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticSchedules", "schedules", "schedules"), + resourceids.UserSpecifiedSegment("scheduleName", "scheduleName"), + } +} + +// String returns a human-readable description of this Schedule ID +func (id ScheduleId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Schedule Name: %q", id.ScheduleName), + } + return fmt.Sprintf("Schedule (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/id_schedule_test.go b/resource-manager/machinelearningservices/2025-04-01/schedule/id_schedule_test.go new file mode 100644 index 00000000000..26f0dac2a3a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/id_schedule_test.go @@ -0,0 +1,327 @@ +package schedule + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ScheduleId{} + +func TestNewScheduleID(t *testing.T) { + id := NewScheduleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "scheduleName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.ScheduleName != "scheduleName" { + t.Fatalf("Expected %q but got %q for Segment 'ScheduleName'", id.ScheduleName, "scheduleName") + } +} + +func TestFormatScheduleID(t *testing.T) { + actual := NewScheduleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "scheduleName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/schedules/scheduleName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseScheduleID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScheduleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/schedules", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/schedules/scheduleName", + Expected: &ScheduleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + ScheduleName: "scheduleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/schedules/scheduleName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScheduleID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.ScheduleName != v.Expected.ScheduleName { + t.Fatalf("Expected %q but got %q for ScheduleName", v.Expected.ScheduleName, actual.ScheduleName) + } + + } +} + +func TestParseScheduleIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ScheduleId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/schedules", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/sChEdUlEs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/schedules/scheduleName", + Expected: &ScheduleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + ScheduleName: "scheduleName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/schedules/scheduleName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/sChEdUlEs/sChEdUlEnAmE", + Expected: &ScheduleId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + ScheduleName: "sChEdUlEnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/sChEdUlEs/sChEdUlEnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseScheduleIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.ScheduleName != v.Expected.ScheduleName { + t.Fatalf("Expected %q but got %q for ScheduleName", v.Expected.ScheduleName, actual.ScheduleName) + } + + } +} + +func TestSegmentsForScheduleId(t *testing.T) { + segments := ScheduleId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ScheduleId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/id_workspace.go b/resource-manager/machinelearningservices/2025-04-01/schedule/id_workspace.go new file mode 100644 index 00000000000..ea6a4fc7058 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/id_workspace.go @@ -0,0 +1,130 @@ +package schedule + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/id_workspace_test.go b/resource-manager/machinelearningservices/2025-04-01/schedule/id_workspace_test.go new file mode 100644 index 00000000000..35d987df638 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/id_workspace_test.go @@ -0,0 +1,282 @@ +package schedule + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/method_createorupdate.go b/resource-manager/machinelearningservices/2025-04-01/schedule/method_createorupdate.go new file mode 100644 index 00000000000..8dd2eeaa978 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/method_createorupdate.go @@ -0,0 +1,75 @@ +package schedule + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ScheduleResource +} + +// CreateOrUpdate ... +func (c ScheduleClient) CreateOrUpdate(ctx context.Context, id ScheduleId, input ScheduleResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ScheduleClient) CreateOrUpdateThenPoll(ctx context.Context, id ScheduleId, input ScheduleResource) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/method_delete.go b/resource-manager/machinelearningservices/2025-04-01/schedule/method_delete.go new file mode 100644 index 00000000000..dd45b55709c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/method_delete.go @@ -0,0 +1,71 @@ +package schedule + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 ScheduleClient) Delete(ctx context.Context, id ScheduleId) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c ScheduleClient) DeleteThenPoll(ctx context.Context, id ScheduleId) 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/machinelearningservices/2025-04-01/schedule/method_get.go b/resource-manager/machinelearningservices/2025-04-01/schedule/method_get.go new file mode 100644 index 00000000000..b50dd6a7fb2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/method_get.go @@ -0,0 +1,53 @@ +package schedule + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ScheduleResource +} + +// Get ... +func (c ScheduleClient) Get(ctx context.Context, id ScheduleId) (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 ScheduleResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/method_list.go b/resource-manager/machinelearningservices/2025-04-01/schedule/method_list.go new file mode 100644 index 00000000000..f2819321b9f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/method_list.go @@ -0,0 +1,138 @@ +package schedule + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]ScheduleResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ScheduleResource +} + +type ListOperationOptions struct { + ListViewType *ScheduleListViewType + Skip *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.ListViewType != nil { + out.Append("listViewType", fmt.Sprintf("%v", *o.ListViewType)) + } + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + 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 ScheduleClient) List(ctx context.Context, id WorkspaceId, 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/schedules", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ScheduleResource `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 ScheduleClient) ListComplete(ctx context.Context, id WorkspaceId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ScheduleResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ScheduleClient) ListCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, options ListOperationOptions, predicate ScheduleResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ScheduleResource, 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/machinelearningservices/2025-04-01/schedule/model_allfeatures.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_allfeatures.go new file mode 100644 index 00000000000..c1fde8b5908 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_allfeatures.go @@ -0,0 +1,49 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ MonitoringFeatureFilterBase = AllFeatures{} + +type AllFeatures struct { + + // Fields inherited from MonitoringFeatureFilterBase + + FilterType MonitoringFeatureFilterType `json:"filterType"` +} + +func (s AllFeatures) MonitoringFeatureFilterBase() BaseMonitoringFeatureFilterBaseImpl { + return BaseMonitoringFeatureFilterBaseImpl{ + FilterType: s.FilterType, + } +} + +var _ json.Marshaler = AllFeatures{} + +func (s AllFeatures) MarshalJSON() ([]byte, error) { + type wrapper AllFeatures + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AllFeatures: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AllFeatures: %+v", err) + } + + decoded["filterType"] = "AllFeatures" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AllFeatures: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_allnodes.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_allnodes.go new file mode 100644 index 00000000000..56e9f737e80 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_allnodes.go @@ -0,0 +1,49 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Nodes = AllNodes{} + +type AllNodes struct { + + // Fields inherited from Nodes + + NodesValueType NodesValueType `json:"nodesValueType"` +} + +func (s AllNodes) Nodes() BaseNodesImpl { + return BaseNodesImpl{ + NodesValueType: s.NodesValueType, + } +} + +var _ json.Marshaler = AllNodes{} + +func (s AllNodes) MarshalJSON() ([]byte, error) { + type wrapper AllNodes + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AllNodes: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AllNodes: %+v", err) + } + + decoded["nodesValueType"] = "All" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AllNodes: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_amltoken.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_amltoken.go new file mode 100644 index 00000000000..894beaee446 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_amltoken.go @@ -0,0 +1,49 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ IdentityConfiguration = AmlToken{} + +type AmlToken struct { + + // Fields inherited from IdentityConfiguration + + IdentityType IdentityConfigurationType `json:"identityType"` +} + +func (s AmlToken) IdentityConfiguration() BaseIdentityConfigurationImpl { + return BaseIdentityConfigurationImpl{ + IdentityType: s.IdentityType, + } +} + +var _ json.Marshaler = AmlToken{} + +func (s AmlToken) MarshalJSON() ([]byte, error) { + type wrapper AmlToken + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AmlToken: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AmlToken: %+v", err) + } + + decoded["identityType"] = "AMLToken" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AmlToken: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_amltokencomputeidentity.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_amltokencomputeidentity.go new file mode 100644 index 00000000000..297ce814499 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_amltokencomputeidentity.go @@ -0,0 +1,49 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ MonitorComputeIdentityBase = AmlTokenComputeIdentity{} + +type AmlTokenComputeIdentity struct { + + // Fields inherited from MonitorComputeIdentityBase + + ComputeIdentityType MonitorComputeIdentityType `json:"computeIdentityType"` +} + +func (s AmlTokenComputeIdentity) MonitorComputeIdentityBase() BaseMonitorComputeIdentityBaseImpl { + return BaseMonitorComputeIdentityBaseImpl{ + ComputeIdentityType: s.ComputeIdentityType, + } +} + +var _ json.Marshaler = AmlTokenComputeIdentity{} + +func (s AmlTokenComputeIdentity) MarshalJSON() ([]byte, error) { + type wrapper AmlTokenComputeIdentity + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AmlTokenComputeIdentity: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AmlTokenComputeIdentity: %+v", err) + } + + decoded["computeIdentityType"] = "AmlToken" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AmlTokenComputeIdentity: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_autoforecasthorizon.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_autoforecasthorizon.go new file mode 100644 index 00000000000..c1472390946 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_autoforecasthorizon.go @@ -0,0 +1,49 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ForecastHorizon = AutoForecastHorizon{} + +type AutoForecastHorizon struct { + + // Fields inherited from ForecastHorizon + + Mode ForecastHorizonMode `json:"mode"` +} + +func (s AutoForecastHorizon) ForecastHorizon() BaseForecastHorizonImpl { + return BaseForecastHorizonImpl{ + Mode: s.Mode, + } +} + +var _ json.Marshaler = AutoForecastHorizon{} + +func (s AutoForecastHorizon) MarshalJSON() ([]byte, error) { + type wrapper AutoForecastHorizon + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AutoForecastHorizon: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AutoForecastHorizon: %+v", err) + } + + decoded["mode"] = "Auto" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AutoForecastHorizon: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_automljob.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_automljob.go new file mode 100644 index 00000000000..bbca9775bc1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_automljob.go @@ -0,0 +1,162 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobBase = AutoMLJob{} + +type AutoMLJob struct { + EnvironmentId *string `json:"environmentId,omitempty"` + EnvironmentVariables *map[string]string `json:"environmentVariables,omitempty"` + Outputs *map[string]JobOutput `json:"outputs,omitempty"` + QueueSettings *QueueSettings `json:"queueSettings,omitempty"` + Resources *JobResourceConfiguration `json:"resources,omitempty"` + TaskDetails AutoMLVertical `json:"taskDetails"` + + // Fields inherited from JobBase + + ComponentId *string `json:"componentId,omitempty"` + ComputeId *string `json:"computeId,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExperimentName *string `json:"experimentName,omitempty"` + Identity IdentityConfiguration `json:"identity"` + IsArchived *bool `json:"isArchived,omitempty"` + JobType JobType `json:"jobType"` + NotificationSetting *NotificationSetting `json:"notificationSetting,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Services *map[string]JobService `json:"services,omitempty"` + Status *JobStatus `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +func (s AutoMLJob) JobBase() BaseJobBaseImpl { + return BaseJobBaseImpl{ + ComponentId: s.ComponentId, + ComputeId: s.ComputeId, + Description: s.Description, + DisplayName: s.DisplayName, + ExperimentName: s.ExperimentName, + Identity: s.Identity, + IsArchived: s.IsArchived, + JobType: s.JobType, + NotificationSetting: s.NotificationSetting, + Properties: s.Properties, + Services: s.Services, + Status: s.Status, + Tags: s.Tags, + } +} + +var _ json.Marshaler = AutoMLJob{} + +func (s AutoMLJob) MarshalJSON() ([]byte, error) { + type wrapper AutoMLJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AutoMLJob: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AutoMLJob: %+v", err) + } + + decoded["jobType"] = "AutoML" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AutoMLJob: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &AutoMLJob{} + +func (s *AutoMLJob) UnmarshalJSON(bytes []byte) error { + var decoded struct { + EnvironmentId *string `json:"environmentId,omitempty"` + EnvironmentVariables *map[string]string `json:"environmentVariables,omitempty"` + QueueSettings *QueueSettings `json:"queueSettings,omitempty"` + Resources *JobResourceConfiguration `json:"resources,omitempty"` + ComponentId *string `json:"componentId,omitempty"` + ComputeId *string `json:"computeId,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExperimentName *string `json:"experimentName,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + JobType JobType `json:"jobType"` + NotificationSetting *NotificationSetting `json:"notificationSetting,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Services *map[string]JobService `json:"services,omitempty"` + Status *JobStatus `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.EnvironmentId = decoded.EnvironmentId + s.EnvironmentVariables = decoded.EnvironmentVariables + s.QueueSettings = decoded.QueueSettings + s.Resources = decoded.Resources + s.ComponentId = decoded.ComponentId + s.ComputeId = decoded.ComputeId + s.Description = decoded.Description + s.DisplayName = decoded.DisplayName + s.ExperimentName = decoded.ExperimentName + s.IsArchived = decoded.IsArchived + s.JobType = decoded.JobType + s.NotificationSetting = decoded.NotificationSetting + s.Properties = decoded.Properties + s.Services = decoded.Services + s.Status = decoded.Status + s.Tags = decoded.Tags + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling AutoMLJob into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["identity"]; ok { + impl, err := UnmarshalIdentityConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Identity' for 'AutoMLJob': %+v", err) + } + s.Identity = impl + } + + if v, ok := temp["outputs"]; ok { + var dictionaryTemp map[string]json.RawMessage + if err := json.Unmarshal(v, &dictionaryTemp); err != nil { + return fmt.Errorf("unmarshaling Outputs into dictionary map[string]json.RawMessage: %+v", err) + } + + output := make(map[string]JobOutput) + for key, val := range dictionaryTemp { + impl, err := UnmarshalJobOutputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling key %q field 'Outputs' for 'AutoMLJob': %+v", key, err) + } + output[key] = impl + } + s.Outputs = &output + } + + if v, ok := temp["taskDetails"]; ok { + impl, err := UnmarshalAutoMLVerticalImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'TaskDetails' for 'AutoMLJob': %+v", err) + } + s.TaskDetails = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_automlvertical.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_automlvertical.go new file mode 100644 index 00000000000..607c0c14555 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_automlvertical.go @@ -0,0 +1,150 @@ +package schedule + +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 AutoMLVertical interface { + AutoMLVertical() BaseAutoMLVerticalImpl +} + +var _ AutoMLVertical = BaseAutoMLVerticalImpl{} + +type BaseAutoMLVerticalImpl struct { + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` +} + +func (s BaseAutoMLVerticalImpl) AutoMLVertical() BaseAutoMLVerticalImpl { + return s +} + +var _ AutoMLVertical = RawAutoMLVerticalImpl{} + +// RawAutoMLVerticalImpl 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 RawAutoMLVerticalImpl struct { + autoMLVertical BaseAutoMLVerticalImpl + Type string + Values map[string]interface{} +} + +func (s RawAutoMLVerticalImpl) AutoMLVertical() BaseAutoMLVerticalImpl { + return s.autoMLVertical +} + +func UnmarshalAutoMLVerticalImplementation(input []byte) (AutoMLVertical, 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 AutoMLVertical into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["taskType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Classification") { + var out Classification + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into Classification: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Forecasting") { + var out Forecasting + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into Forecasting: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ImageClassification") { + var out ImageClassification + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ImageClassification: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ImageClassificationMultilabel") { + var out ImageClassificationMultilabel + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ImageClassificationMultilabel: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ImageInstanceSegmentation") { + var out ImageInstanceSegmentation + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ImageInstanceSegmentation: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ImageObjectDetection") { + var out ImageObjectDetection + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ImageObjectDetection: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Regression") { + var out Regression + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into Regression: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "TextClassification") { + var out TextClassification + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into TextClassification: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "TextClassificationMultilabel") { + var out TextClassificationMultilabel + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into TextClassificationMultilabel: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "TextNER") { + var out TextNer + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into TextNer: %+v", err) + } + return out, nil + } + + var parent BaseAutoMLVerticalImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseAutoMLVerticalImpl: %+v", err) + } + + return RawAutoMLVerticalImpl{ + autoMLVertical: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_autoncrossvalidations.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_autoncrossvalidations.go new file mode 100644 index 00000000000..675fe5a7287 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_autoncrossvalidations.go @@ -0,0 +1,49 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ NCrossValidations = AutoNCrossValidations{} + +type AutoNCrossValidations struct { + + // Fields inherited from NCrossValidations + + Mode NCrossValidationsMode `json:"mode"` +} + +func (s AutoNCrossValidations) NCrossValidations() BaseNCrossValidationsImpl { + return BaseNCrossValidationsImpl{ + Mode: s.Mode, + } +} + +var _ json.Marshaler = AutoNCrossValidations{} + +func (s AutoNCrossValidations) MarshalJSON() ([]byte, error) { + type wrapper AutoNCrossValidations + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AutoNCrossValidations: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AutoNCrossValidations: %+v", err) + } + + decoded["mode"] = "Auto" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AutoNCrossValidations: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_autoseasonality.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_autoseasonality.go new file mode 100644 index 00000000000..1c55a12f9a7 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_autoseasonality.go @@ -0,0 +1,49 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Seasonality = AutoSeasonality{} + +type AutoSeasonality struct { + + // Fields inherited from Seasonality + + Mode SeasonalityMode `json:"mode"` +} + +func (s AutoSeasonality) Seasonality() BaseSeasonalityImpl { + return BaseSeasonalityImpl{ + Mode: s.Mode, + } +} + +var _ json.Marshaler = AutoSeasonality{} + +func (s AutoSeasonality) MarshalJSON() ([]byte, error) { + type wrapper AutoSeasonality + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AutoSeasonality: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AutoSeasonality: %+v", err) + } + + decoded["mode"] = "Auto" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AutoSeasonality: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_autotargetlags.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_autotargetlags.go new file mode 100644 index 00000000000..ba78e9c6512 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_autotargetlags.go @@ -0,0 +1,49 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TargetLags = AutoTargetLags{} + +type AutoTargetLags struct { + + // Fields inherited from TargetLags + + Mode TargetLagsMode `json:"mode"` +} + +func (s AutoTargetLags) TargetLags() BaseTargetLagsImpl { + return BaseTargetLagsImpl{ + Mode: s.Mode, + } +} + +var _ json.Marshaler = AutoTargetLags{} + +func (s AutoTargetLags) MarshalJSON() ([]byte, error) { + type wrapper AutoTargetLags + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AutoTargetLags: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AutoTargetLags: %+v", err) + } + + decoded["mode"] = "Auto" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AutoTargetLags: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_autotargetrollingwindowsize.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_autotargetrollingwindowsize.go new file mode 100644 index 00000000000..60721dec678 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_autotargetrollingwindowsize.go @@ -0,0 +1,49 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TargetRollingWindowSize = AutoTargetRollingWindowSize{} + +type AutoTargetRollingWindowSize struct { + + // Fields inherited from TargetRollingWindowSize + + Mode TargetRollingWindowSizeMode `json:"mode"` +} + +func (s AutoTargetRollingWindowSize) TargetRollingWindowSize() BaseTargetRollingWindowSizeImpl { + return BaseTargetRollingWindowSizeImpl{ + Mode: s.Mode, + } +} + +var _ json.Marshaler = AutoTargetRollingWindowSize{} + +func (s AutoTargetRollingWindowSize) MarshalJSON() ([]byte, error) { + type wrapper AutoTargetRollingWindowSize + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AutoTargetRollingWindowSize: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AutoTargetRollingWindowSize: %+v", err) + } + + decoded["mode"] = "Auto" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AutoTargetRollingWindowSize: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_azuredevopswebhook.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_azuredevopswebhook.go new file mode 100644 index 00000000000..d6f8be1bd68 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_azuredevopswebhook.go @@ -0,0 +1,51 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Webhook = AzureDevOpsWebhook{} + +type AzureDevOpsWebhook struct { + + // Fields inherited from Webhook + + EventType *string `json:"eventType,omitempty"` + WebhookType WebhookType `json:"webhookType"` +} + +func (s AzureDevOpsWebhook) Webhook() BaseWebhookImpl { + return BaseWebhookImpl{ + EventType: s.EventType, + WebhookType: s.WebhookType, + } +} + +var _ json.Marshaler = AzureDevOpsWebhook{} + +func (s AzureDevOpsWebhook) MarshalJSON() ([]byte, error) { + type wrapper AzureDevOpsWebhook + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AzureDevOpsWebhook: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AzureDevOpsWebhook: %+v", err) + } + + decoded["webhookType"] = "AzureDevOps" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AzureDevOpsWebhook: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_banditpolicy.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_banditpolicy.go new file mode 100644 index 00000000000..31e2b60bebc --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_banditpolicy.go @@ -0,0 +1,55 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EarlyTerminationPolicy = BanditPolicy{} + +type BanditPolicy struct { + SlackAmount *float64 `json:"slackAmount,omitempty"` + SlackFactor *float64 `json:"slackFactor,omitempty"` + + // Fields inherited from EarlyTerminationPolicy + + DelayEvaluation *int64 `json:"delayEvaluation,omitempty"` + EvaluationInterval *int64 `json:"evaluationInterval,omitempty"` + PolicyType EarlyTerminationPolicyType `json:"policyType"` +} + +func (s BanditPolicy) EarlyTerminationPolicy() BaseEarlyTerminationPolicyImpl { + return BaseEarlyTerminationPolicyImpl{ + DelayEvaluation: s.DelayEvaluation, + EvaluationInterval: s.EvaluationInterval, + PolicyType: s.PolicyType, + } +} + +var _ json.Marshaler = BanditPolicy{} + +func (s BanditPolicy) MarshalJSON() ([]byte, error) { + type wrapper BanditPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling BanditPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling BanditPolicy: %+v", err) + } + + decoded["policyType"] = "Bandit" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling BanditPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_bayesiansamplingalgorithm.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_bayesiansamplingalgorithm.go new file mode 100644 index 00000000000..be893b96cad --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_bayesiansamplingalgorithm.go @@ -0,0 +1,49 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SamplingAlgorithm = BayesianSamplingAlgorithm{} + +type BayesianSamplingAlgorithm struct { + + // Fields inherited from SamplingAlgorithm + + SamplingAlgorithmType SamplingAlgorithmType `json:"samplingAlgorithmType"` +} + +func (s BayesianSamplingAlgorithm) SamplingAlgorithm() BaseSamplingAlgorithmImpl { + return BaseSamplingAlgorithmImpl{ + SamplingAlgorithmType: s.SamplingAlgorithmType, + } +} + +var _ json.Marshaler = BayesianSamplingAlgorithm{} + +func (s BayesianSamplingAlgorithm) MarshalJSON() ([]byte, error) { + type wrapper BayesianSamplingAlgorithm + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling BayesianSamplingAlgorithm: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling BayesianSamplingAlgorithm: %+v", err) + } + + decoded["samplingAlgorithmType"] = "Bayesian" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling BayesianSamplingAlgorithm: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_categoricaldatadriftmetricthreshold.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_categoricaldatadriftmetricthreshold.go new file mode 100644 index 00000000000..0f6b9516e9d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_categoricaldatadriftmetricthreshold.go @@ -0,0 +1,52 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DataDriftMetricThresholdBase = CategoricalDataDriftMetricThreshold{} + +type CategoricalDataDriftMetricThreshold struct { + Metric CategoricalDataDriftMetric `json:"metric"` + + // Fields inherited from DataDriftMetricThresholdBase + + DataType MonitoringFeatureDataType `json:"dataType"` + Threshold *MonitoringThreshold `json:"threshold,omitempty"` +} + +func (s CategoricalDataDriftMetricThreshold) DataDriftMetricThresholdBase() BaseDataDriftMetricThresholdBaseImpl { + return BaseDataDriftMetricThresholdBaseImpl{ + DataType: s.DataType, + Threshold: s.Threshold, + } +} + +var _ json.Marshaler = CategoricalDataDriftMetricThreshold{} + +func (s CategoricalDataDriftMetricThreshold) MarshalJSON() ([]byte, error) { + type wrapper CategoricalDataDriftMetricThreshold + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CategoricalDataDriftMetricThreshold: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CategoricalDataDriftMetricThreshold: %+v", err) + } + + decoded["dataType"] = "Categorical" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CategoricalDataDriftMetricThreshold: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_categoricaldataqualitymetricthreshold.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_categoricaldataqualitymetricthreshold.go new file mode 100644 index 00000000000..c9f0a057e9a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_categoricaldataqualitymetricthreshold.go @@ -0,0 +1,52 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DataQualityMetricThresholdBase = CategoricalDataQualityMetricThreshold{} + +type CategoricalDataQualityMetricThreshold struct { + Metric CategoricalDataQualityMetric `json:"metric"` + + // Fields inherited from DataQualityMetricThresholdBase + + DataType MonitoringFeatureDataType `json:"dataType"` + Threshold *MonitoringThreshold `json:"threshold,omitempty"` +} + +func (s CategoricalDataQualityMetricThreshold) DataQualityMetricThresholdBase() BaseDataQualityMetricThresholdBaseImpl { + return BaseDataQualityMetricThresholdBaseImpl{ + DataType: s.DataType, + Threshold: s.Threshold, + } +} + +var _ json.Marshaler = CategoricalDataQualityMetricThreshold{} + +func (s CategoricalDataQualityMetricThreshold) MarshalJSON() ([]byte, error) { + type wrapper CategoricalDataQualityMetricThreshold + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CategoricalDataQualityMetricThreshold: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CategoricalDataQualityMetricThreshold: %+v", err) + } + + decoded["dataType"] = "Categorical" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CategoricalDataQualityMetricThreshold: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_categoricalpredictiondriftmetricthreshold.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_categoricalpredictiondriftmetricthreshold.go new file mode 100644 index 00000000000..64d49299a8c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_categoricalpredictiondriftmetricthreshold.go @@ -0,0 +1,52 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PredictionDriftMetricThresholdBase = CategoricalPredictionDriftMetricThreshold{} + +type CategoricalPredictionDriftMetricThreshold struct { + Metric CategoricalPredictionDriftMetric `json:"metric"` + + // Fields inherited from PredictionDriftMetricThresholdBase + + DataType MonitoringFeatureDataType `json:"dataType"` + Threshold *MonitoringThreshold `json:"threshold,omitempty"` +} + +func (s CategoricalPredictionDriftMetricThreshold) PredictionDriftMetricThresholdBase() BasePredictionDriftMetricThresholdBaseImpl { + return BasePredictionDriftMetricThresholdBaseImpl{ + DataType: s.DataType, + Threshold: s.Threshold, + } +} + +var _ json.Marshaler = CategoricalPredictionDriftMetricThreshold{} + +func (s CategoricalPredictionDriftMetricThreshold) MarshalJSON() ([]byte, error) { + type wrapper CategoricalPredictionDriftMetricThreshold + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CategoricalPredictionDriftMetricThreshold: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CategoricalPredictionDriftMetricThreshold: %+v", err) + } + + decoded["dataType"] = "Categorical" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CategoricalPredictionDriftMetricThreshold: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_classification.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_classification.go new file mode 100644 index 00000000000..78e6ee14875 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_classification.go @@ -0,0 +1,123 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AutoMLVertical = Classification{} + +type Classification struct { + CvSplitColumnNames *[]string `json:"cvSplitColumnNames,omitempty"` + FeaturizationSettings *TableVerticalFeaturizationSettings `json:"featurizationSettings,omitempty"` + LimitSettings *TableVerticalLimitSettings `json:"limitSettings,omitempty"` + NCrossValidations NCrossValidations `json:"nCrossValidations"` + PositiveLabel *string `json:"positiveLabel,omitempty"` + PrimaryMetric *ClassificationPrimaryMetrics `json:"primaryMetric,omitempty"` + TestData *MLTableJobInput `json:"testData,omitempty"` + TestDataSize *float64 `json:"testDataSize,omitempty"` + TrainingSettings *ClassificationTrainingSettings `json:"trainingSettings,omitempty"` + ValidationData *MLTableJobInput `json:"validationData,omitempty"` + ValidationDataSize *float64 `json:"validationDataSize,omitempty"` + WeightColumnName *string `json:"weightColumnName,omitempty"` + + // Fields inherited from AutoMLVertical + + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` +} + +func (s Classification) AutoMLVertical() BaseAutoMLVerticalImpl { + return BaseAutoMLVerticalImpl{ + LogVerbosity: s.LogVerbosity, + TargetColumnName: s.TargetColumnName, + TaskType: s.TaskType, + TrainingData: s.TrainingData, + } +} + +var _ json.Marshaler = Classification{} + +func (s Classification) MarshalJSON() ([]byte, error) { + type wrapper Classification + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling Classification: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling Classification: %+v", err) + } + + decoded["taskType"] = "Classification" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling Classification: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &Classification{} + +func (s *Classification) UnmarshalJSON(bytes []byte) error { + var decoded struct { + CvSplitColumnNames *[]string `json:"cvSplitColumnNames,omitempty"` + FeaturizationSettings *TableVerticalFeaturizationSettings `json:"featurizationSettings,omitempty"` + LimitSettings *TableVerticalLimitSettings `json:"limitSettings,omitempty"` + PositiveLabel *string `json:"positiveLabel,omitempty"` + PrimaryMetric *ClassificationPrimaryMetrics `json:"primaryMetric,omitempty"` + TestData *MLTableJobInput `json:"testData,omitempty"` + TestDataSize *float64 `json:"testDataSize,omitempty"` + TrainingSettings *ClassificationTrainingSettings `json:"trainingSettings,omitempty"` + ValidationData *MLTableJobInput `json:"validationData,omitempty"` + ValidationDataSize *float64 `json:"validationDataSize,omitempty"` + WeightColumnName *string `json:"weightColumnName,omitempty"` + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.CvSplitColumnNames = decoded.CvSplitColumnNames + s.FeaturizationSettings = decoded.FeaturizationSettings + s.LimitSettings = decoded.LimitSettings + s.PositiveLabel = decoded.PositiveLabel + s.PrimaryMetric = decoded.PrimaryMetric + s.TestData = decoded.TestData + s.TestDataSize = decoded.TestDataSize + s.TrainingSettings = decoded.TrainingSettings + s.ValidationData = decoded.ValidationData + s.ValidationDataSize = decoded.ValidationDataSize + s.WeightColumnName = decoded.WeightColumnName + s.LogVerbosity = decoded.LogVerbosity + s.TargetColumnName = decoded.TargetColumnName + s.TaskType = decoded.TaskType + s.TrainingData = decoded.TrainingData + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling Classification into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["nCrossValidations"]; ok { + impl, err := UnmarshalNCrossValidationsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'NCrossValidations' for 'Classification': %+v", err) + } + s.NCrossValidations = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_classificationtrainingsettings.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_classificationtrainingsettings.go new file mode 100644 index 00000000000..7e3c91d9d90 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_classificationtrainingsettings.go @@ -0,0 +1,16 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ClassificationTrainingSettings struct { + AllowedTrainingAlgorithms *[]ClassificationModels `json:"allowedTrainingAlgorithms,omitempty"` + BlockedTrainingAlgorithms *[]ClassificationModels `json:"blockedTrainingAlgorithms,omitempty"` + EnableDnnTraining *bool `json:"enableDnnTraining,omitempty"` + EnableModelExplainability *bool `json:"enableModelExplainability,omitempty"` + EnableOnnxCompatibleModels *bool `json:"enableOnnxCompatibleModels,omitempty"` + EnableStackEnsemble *bool `json:"enableStackEnsemble,omitempty"` + EnableVoteEnsemble *bool `json:"enableVoteEnsemble,omitempty"` + EnsembleModelDownloadTimeout *string `json:"ensembleModelDownloadTimeout,omitempty"` + StackEnsembleSettings *StackEnsembleSettings `json:"stackEnsembleSettings,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_columntransformer.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_columntransformer.go new file mode 100644 index 00000000000..b3980276e7e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_columntransformer.go @@ -0,0 +1,9 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ColumnTransformer struct { + Fields *[]string `json:"fields,omitempty"` + Parameters *interface{} `json:"parameters,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_commandjob.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_commandjob.go new file mode 100644 index 00000000000..b9c96b86ab1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_commandjob.go @@ -0,0 +1,198 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobBase = CommandJob{} + +type CommandJob struct { + CodeId *string `json:"codeId,omitempty"` + Command string `json:"command"` + Distribution DistributionConfiguration `json:"distribution"` + EnvironmentId string `json:"environmentId"` + EnvironmentVariables *map[string]string `json:"environmentVariables,omitempty"` + Inputs *map[string]JobInput `json:"inputs,omitempty"` + Limits JobLimits `json:"limits"` + Outputs *map[string]JobOutput `json:"outputs,omitempty"` + Parameters *interface{} `json:"parameters,omitempty"` + QueueSettings *QueueSettings `json:"queueSettings,omitempty"` + Resources *JobResourceConfiguration `json:"resources,omitempty"` + + // Fields inherited from JobBase + + ComponentId *string `json:"componentId,omitempty"` + ComputeId *string `json:"computeId,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExperimentName *string `json:"experimentName,omitempty"` + Identity IdentityConfiguration `json:"identity"` + IsArchived *bool `json:"isArchived,omitempty"` + JobType JobType `json:"jobType"` + NotificationSetting *NotificationSetting `json:"notificationSetting,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Services *map[string]JobService `json:"services,omitempty"` + Status *JobStatus `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +func (s CommandJob) JobBase() BaseJobBaseImpl { + return BaseJobBaseImpl{ + ComponentId: s.ComponentId, + ComputeId: s.ComputeId, + Description: s.Description, + DisplayName: s.DisplayName, + ExperimentName: s.ExperimentName, + Identity: s.Identity, + IsArchived: s.IsArchived, + JobType: s.JobType, + NotificationSetting: s.NotificationSetting, + Properties: s.Properties, + Services: s.Services, + Status: s.Status, + Tags: s.Tags, + } +} + +var _ json.Marshaler = CommandJob{} + +func (s CommandJob) MarshalJSON() ([]byte, error) { + type wrapper CommandJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CommandJob: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CommandJob: %+v", err) + } + + decoded["jobType"] = "Command" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CommandJob: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &CommandJob{} + +func (s *CommandJob) UnmarshalJSON(bytes []byte) error { + var decoded struct { + CodeId *string `json:"codeId,omitempty"` + Command string `json:"command"` + EnvironmentId string `json:"environmentId"` + EnvironmentVariables *map[string]string `json:"environmentVariables,omitempty"` + Parameters *interface{} `json:"parameters,omitempty"` + QueueSettings *QueueSettings `json:"queueSettings,omitempty"` + Resources *JobResourceConfiguration `json:"resources,omitempty"` + ComponentId *string `json:"componentId,omitempty"` + ComputeId *string `json:"computeId,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExperimentName *string `json:"experimentName,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + JobType JobType `json:"jobType"` + NotificationSetting *NotificationSetting `json:"notificationSetting,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Services *map[string]JobService `json:"services,omitempty"` + Status *JobStatus `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.CodeId = decoded.CodeId + s.Command = decoded.Command + s.EnvironmentId = decoded.EnvironmentId + s.EnvironmentVariables = decoded.EnvironmentVariables + s.Parameters = decoded.Parameters + s.QueueSettings = decoded.QueueSettings + s.Resources = decoded.Resources + s.ComponentId = decoded.ComponentId + s.ComputeId = decoded.ComputeId + s.Description = decoded.Description + s.DisplayName = decoded.DisplayName + s.ExperimentName = decoded.ExperimentName + s.IsArchived = decoded.IsArchived + s.JobType = decoded.JobType + s.NotificationSetting = decoded.NotificationSetting + s.Properties = decoded.Properties + s.Services = decoded.Services + s.Status = decoded.Status + s.Tags = decoded.Tags + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling CommandJob into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["distribution"]; ok { + impl, err := UnmarshalDistributionConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Distribution' for 'CommandJob': %+v", err) + } + s.Distribution = impl + } + + if v, ok := temp["identity"]; ok { + impl, err := UnmarshalIdentityConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Identity' for 'CommandJob': %+v", err) + } + s.Identity = impl + } + + if v, ok := temp["inputs"]; ok { + var dictionaryTemp map[string]json.RawMessage + if err := json.Unmarshal(v, &dictionaryTemp); err != nil { + return fmt.Errorf("unmarshaling Inputs into dictionary map[string]json.RawMessage: %+v", err) + } + + output := make(map[string]JobInput) + for key, val := range dictionaryTemp { + impl, err := UnmarshalJobInputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling key %q field 'Inputs' for 'CommandJob': %+v", key, err) + } + output[key] = impl + } + s.Inputs = &output + } + + if v, ok := temp["limits"]; ok { + impl, err := UnmarshalJobLimitsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Limits' for 'CommandJob': %+v", err) + } + s.Limits = impl + } + + if v, ok := temp["outputs"]; ok { + var dictionaryTemp map[string]json.RawMessage + if err := json.Unmarshal(v, &dictionaryTemp); err != nil { + return fmt.Errorf("unmarshaling Outputs into dictionary map[string]json.RawMessage: %+v", err) + } + + output := make(map[string]JobOutput) + for key, val := range dictionaryTemp { + impl, err := UnmarshalJobOutputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling key %q field 'Outputs' for 'CommandJob': %+v", key, err) + } + output[key] = impl + } + s.Outputs = &output + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_commandjoblimits.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_commandjoblimits.go new file mode 100644 index 00000000000..712d95c31ad --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_commandjoblimits.go @@ -0,0 +1,51 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobLimits = CommandJobLimits{} + +type CommandJobLimits struct { + + // Fields inherited from JobLimits + + JobLimitsType JobLimitsType `json:"jobLimitsType"` + Timeout *string `json:"timeout,omitempty"` +} + +func (s CommandJobLimits) JobLimits() BaseJobLimitsImpl { + return BaseJobLimitsImpl{ + JobLimitsType: s.JobLimitsType, + Timeout: s.Timeout, + } +} + +var _ json.Marshaler = CommandJobLimits{} + +func (s CommandJobLimits) MarshalJSON() ([]byte, error) { + type wrapper CommandJobLimits + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CommandJobLimits: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CommandJobLimits: %+v", err) + } + + decoded["jobLimitsType"] = "Command" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CommandJobLimits: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_createmonitoraction.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_createmonitoraction.go new file mode 100644 index 00000000000..54ff25df20b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_createmonitoraction.go @@ -0,0 +1,50 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ScheduleActionBase = CreateMonitorAction{} + +type CreateMonitorAction struct { + MonitorDefinition MonitorDefinition `json:"monitorDefinition"` + + // Fields inherited from ScheduleActionBase + + ActionType ScheduleActionType `json:"actionType"` +} + +func (s CreateMonitorAction) ScheduleActionBase() BaseScheduleActionBaseImpl { + return BaseScheduleActionBaseImpl{ + ActionType: s.ActionType, + } +} + +var _ json.Marshaler = CreateMonitorAction{} + +func (s CreateMonitorAction) MarshalJSON() ([]byte, error) { + type wrapper CreateMonitorAction + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CreateMonitorAction: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CreateMonitorAction: %+v", err) + } + + decoded["actionType"] = "CreateMonitor" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CreateMonitorAction: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_crontrigger.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_crontrigger.go new file mode 100644 index 00000000000..e056080c9e9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_crontrigger.go @@ -0,0 +1,56 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TriggerBase = CronTrigger{} + +type CronTrigger struct { + Expression string `json:"expression"` + + // Fields inherited from TriggerBase + + EndTime *string `json:"endTime,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + TriggerType TriggerType `json:"triggerType"` +} + +func (s CronTrigger) TriggerBase() BaseTriggerBaseImpl { + return BaseTriggerBaseImpl{ + EndTime: s.EndTime, + StartTime: s.StartTime, + TimeZone: s.TimeZone, + TriggerType: s.TriggerType, + } +} + +var _ json.Marshaler = CronTrigger{} + +func (s CronTrigger) MarshalJSON() ([]byte, error) { + type wrapper CronTrigger + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CronTrigger: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CronTrigger: %+v", err) + } + + decoded["triggerType"] = "Cron" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CronTrigger: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_customforecasthorizon.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_customforecasthorizon.go new file mode 100644 index 00000000000..5e2042d6924 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_customforecasthorizon.go @@ -0,0 +1,50 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ForecastHorizon = CustomForecastHorizon{} + +type CustomForecastHorizon struct { + Value int64 `json:"value"` + + // Fields inherited from ForecastHorizon + + Mode ForecastHorizonMode `json:"mode"` +} + +func (s CustomForecastHorizon) ForecastHorizon() BaseForecastHorizonImpl { + return BaseForecastHorizonImpl{ + Mode: s.Mode, + } +} + +var _ json.Marshaler = CustomForecastHorizon{} + +func (s CustomForecastHorizon) MarshalJSON() ([]byte, error) { + type wrapper CustomForecastHorizon + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CustomForecastHorizon: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CustomForecastHorizon: %+v", err) + } + + decoded["mode"] = "Custom" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CustomForecastHorizon: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_custommetricthreshold.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_custommetricthreshold.go new file mode 100644 index 00000000000..09d7cef4ff2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_custommetricthreshold.go @@ -0,0 +1,9 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomMetricThreshold struct { + Metric string `json:"metric"` + Threshold *MonitoringThreshold `json:"threshold,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_custommodeljobinput.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_custommodeljobinput.go new file mode 100644 index 00000000000..b8700d5b750 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_custommodeljobinput.go @@ -0,0 +1,53 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobInput = CustomModelJobInput{} + +type CustomModelJobInput struct { + Mode *InputDeliveryMode `json:"mode,omitempty"` + Uri string `json:"uri"` + + // Fields inherited from JobInput + + Description *string `json:"description,omitempty"` + JobInputType JobInputType `json:"jobInputType"` +} + +func (s CustomModelJobInput) JobInput() BaseJobInputImpl { + return BaseJobInputImpl{ + Description: s.Description, + JobInputType: s.JobInputType, + } +} + +var _ json.Marshaler = CustomModelJobInput{} + +func (s CustomModelJobInput) MarshalJSON() ([]byte, error) { + type wrapper CustomModelJobInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CustomModelJobInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CustomModelJobInput: %+v", err) + } + + decoded["jobInputType"] = "custom_model" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CustomModelJobInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_custommodeljoboutput.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_custommodeljoboutput.go new file mode 100644 index 00000000000..acf90e9e949 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_custommodeljoboutput.go @@ -0,0 +1,53 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobOutput = CustomModelJobOutput{} + +type CustomModelJobOutput struct { + Mode *OutputDeliveryMode `json:"mode,omitempty"` + Uri *string `json:"uri,omitempty"` + + // Fields inherited from JobOutput + + Description *string `json:"description,omitempty"` + JobOutputType JobOutputType `json:"jobOutputType"` +} + +func (s CustomModelJobOutput) JobOutput() BaseJobOutputImpl { + return BaseJobOutputImpl{ + Description: s.Description, + JobOutputType: s.JobOutputType, + } +} + +var _ json.Marshaler = CustomModelJobOutput{} + +func (s CustomModelJobOutput) MarshalJSON() ([]byte, error) { + type wrapper CustomModelJobOutput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CustomModelJobOutput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CustomModelJobOutput: %+v", err) + } + + decoded["jobOutputType"] = "custom_model" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CustomModelJobOutput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_custommonitoringsignal.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_custommonitoringsignal.go new file mode 100644 index 00000000000..1bcc1763a76 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_custommonitoringsignal.go @@ -0,0 +1,119 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ MonitoringSignalBase = CustomMonitoringSignal{} + +type CustomMonitoringSignal struct { + ComponentId string `json:"componentId"` + InputAssets *map[string]MonitoringInputDataBase `json:"inputAssets,omitempty"` + Inputs *map[string]JobInput `json:"inputs,omitempty"` + MetricThresholds []CustomMetricThreshold `json:"metricThresholds"` + + // Fields inherited from MonitoringSignalBase + + NotificationTypes *[]MonitoringNotificationType `json:"notificationTypes,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + SignalType MonitoringSignalType `json:"signalType"` +} + +func (s CustomMonitoringSignal) MonitoringSignalBase() BaseMonitoringSignalBaseImpl { + return BaseMonitoringSignalBaseImpl{ + NotificationTypes: s.NotificationTypes, + Properties: s.Properties, + SignalType: s.SignalType, + } +} + +var _ json.Marshaler = CustomMonitoringSignal{} + +func (s CustomMonitoringSignal) MarshalJSON() ([]byte, error) { + type wrapper CustomMonitoringSignal + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CustomMonitoringSignal: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CustomMonitoringSignal: %+v", err) + } + + decoded["signalType"] = "Custom" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CustomMonitoringSignal: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &CustomMonitoringSignal{} + +func (s *CustomMonitoringSignal) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ComponentId string `json:"componentId"` + MetricThresholds []CustomMetricThreshold `json:"metricThresholds"` + NotificationTypes *[]MonitoringNotificationType `json:"notificationTypes,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + SignalType MonitoringSignalType `json:"signalType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ComponentId = decoded.ComponentId + s.MetricThresholds = decoded.MetricThresholds + s.NotificationTypes = decoded.NotificationTypes + s.Properties = decoded.Properties + s.SignalType = decoded.SignalType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling CustomMonitoringSignal into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["inputAssets"]; ok { + var dictionaryTemp map[string]json.RawMessage + if err := json.Unmarshal(v, &dictionaryTemp); err != nil { + return fmt.Errorf("unmarshaling InputAssets into dictionary map[string]json.RawMessage: %+v", err) + } + + output := make(map[string]MonitoringInputDataBase) + for key, val := range dictionaryTemp { + impl, err := UnmarshalMonitoringInputDataBaseImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling key %q field 'InputAssets' for 'CustomMonitoringSignal': %+v", key, err) + } + output[key] = impl + } + s.InputAssets = &output + } + + if v, ok := temp["inputs"]; ok { + var dictionaryTemp map[string]json.RawMessage + if err := json.Unmarshal(v, &dictionaryTemp); err != nil { + return fmt.Errorf("unmarshaling Inputs into dictionary map[string]json.RawMessage: %+v", err) + } + + output := make(map[string]JobInput) + for key, val := range dictionaryTemp { + impl, err := UnmarshalJobInputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling key %q field 'Inputs' for 'CustomMonitoringSignal': %+v", key, err) + } + output[key] = impl + } + s.Inputs = &output + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_customncrossvalidations.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_customncrossvalidations.go new file mode 100644 index 00000000000..e9fd5d28638 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_customncrossvalidations.go @@ -0,0 +1,50 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ NCrossValidations = CustomNCrossValidations{} + +type CustomNCrossValidations struct { + Value int64 `json:"value"` + + // Fields inherited from NCrossValidations + + Mode NCrossValidationsMode `json:"mode"` +} + +func (s CustomNCrossValidations) NCrossValidations() BaseNCrossValidationsImpl { + return BaseNCrossValidationsImpl{ + Mode: s.Mode, + } +} + +var _ json.Marshaler = CustomNCrossValidations{} + +func (s CustomNCrossValidations) MarshalJSON() ([]byte, error) { + type wrapper CustomNCrossValidations + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CustomNCrossValidations: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CustomNCrossValidations: %+v", err) + } + + decoded["mode"] = "Custom" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CustomNCrossValidations: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_customseasonality.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_customseasonality.go new file mode 100644 index 00000000000..5bda357d48a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_customseasonality.go @@ -0,0 +1,50 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ Seasonality = CustomSeasonality{} + +type CustomSeasonality struct { + Value int64 `json:"value"` + + // Fields inherited from Seasonality + + Mode SeasonalityMode `json:"mode"` +} + +func (s CustomSeasonality) Seasonality() BaseSeasonalityImpl { + return BaseSeasonalityImpl{ + Mode: s.Mode, + } +} + +var _ json.Marshaler = CustomSeasonality{} + +func (s CustomSeasonality) MarshalJSON() ([]byte, error) { + type wrapper CustomSeasonality + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CustomSeasonality: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CustomSeasonality: %+v", err) + } + + decoded["mode"] = "Custom" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CustomSeasonality: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_customtargetlags.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_customtargetlags.go new file mode 100644 index 00000000000..546e8dd0b84 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_customtargetlags.go @@ -0,0 +1,50 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TargetLags = CustomTargetLags{} + +type CustomTargetLags struct { + Values []int64 `json:"values"` + + // Fields inherited from TargetLags + + Mode TargetLagsMode `json:"mode"` +} + +func (s CustomTargetLags) TargetLags() BaseTargetLagsImpl { + return BaseTargetLagsImpl{ + Mode: s.Mode, + } +} + +var _ json.Marshaler = CustomTargetLags{} + +func (s CustomTargetLags) MarshalJSON() ([]byte, error) { + type wrapper CustomTargetLags + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CustomTargetLags: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CustomTargetLags: %+v", err) + } + + decoded["mode"] = "Custom" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CustomTargetLags: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_customtargetrollingwindowsize.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_customtargetrollingwindowsize.go new file mode 100644 index 00000000000..d224ed243de --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_customtargetrollingwindowsize.go @@ -0,0 +1,50 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TargetRollingWindowSize = CustomTargetRollingWindowSize{} + +type CustomTargetRollingWindowSize struct { + Value int64 `json:"value"` + + // Fields inherited from TargetRollingWindowSize + + Mode TargetRollingWindowSizeMode `json:"mode"` +} + +func (s CustomTargetRollingWindowSize) TargetRollingWindowSize() BaseTargetRollingWindowSizeImpl { + return BaseTargetRollingWindowSizeImpl{ + Mode: s.Mode, + } +} + +var _ json.Marshaler = CustomTargetRollingWindowSize{} + +func (s CustomTargetRollingWindowSize) MarshalJSON() ([]byte, error) { + type wrapper CustomTargetRollingWindowSize + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CustomTargetRollingWindowSize: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CustomTargetRollingWindowSize: %+v", err) + } + + decoded["mode"] = "Custom" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CustomTargetRollingWindowSize: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_datadriftmetricthresholdbase.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_datadriftmetricthresholdbase.go new file mode 100644 index 00000000000..7d35f0f65db --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_datadriftmetricthresholdbase.go @@ -0,0 +1,84 @@ +package schedule + +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 DataDriftMetricThresholdBase interface { + DataDriftMetricThresholdBase() BaseDataDriftMetricThresholdBaseImpl +} + +var _ DataDriftMetricThresholdBase = BaseDataDriftMetricThresholdBaseImpl{} + +type BaseDataDriftMetricThresholdBaseImpl struct { + DataType MonitoringFeatureDataType `json:"dataType"` + Threshold *MonitoringThreshold `json:"threshold,omitempty"` +} + +func (s BaseDataDriftMetricThresholdBaseImpl) DataDriftMetricThresholdBase() BaseDataDriftMetricThresholdBaseImpl { + return s +} + +var _ DataDriftMetricThresholdBase = RawDataDriftMetricThresholdBaseImpl{} + +// RawDataDriftMetricThresholdBaseImpl 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 RawDataDriftMetricThresholdBaseImpl struct { + dataDriftMetricThresholdBase BaseDataDriftMetricThresholdBaseImpl + Type string + Values map[string]interface{} +} + +func (s RawDataDriftMetricThresholdBaseImpl) DataDriftMetricThresholdBase() BaseDataDriftMetricThresholdBaseImpl { + return s.dataDriftMetricThresholdBase +} + +func UnmarshalDataDriftMetricThresholdBaseImplementation(input []byte) (DataDriftMetricThresholdBase, 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 DataDriftMetricThresholdBase into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["dataType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Categorical") { + var out CategoricalDataDriftMetricThreshold + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CategoricalDataDriftMetricThreshold: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Numerical") { + var out NumericalDataDriftMetricThreshold + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into NumericalDataDriftMetricThreshold: %+v", err) + } + return out, nil + } + + var parent BaseDataDriftMetricThresholdBaseImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseDataDriftMetricThresholdBaseImpl: %+v", err) + } + + return RawDataDriftMetricThresholdBaseImpl{ + dataDriftMetricThresholdBase: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_datadriftmonitoringsignal.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_datadriftmonitoringsignal.go new file mode 100644 index 00000000000..533ee07774a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_datadriftmonitoringsignal.go @@ -0,0 +1,128 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ MonitoringSignalBase = DataDriftMonitoringSignal{} + +type DataDriftMonitoringSignal struct { + FeatureDataTypeOverride *map[string]MonitoringFeatureDataType `json:"featureDataTypeOverride,omitempty"` + FeatureImportanceSettings *FeatureImportanceSettings `json:"featureImportanceSettings,omitempty"` + Features MonitoringFeatureFilterBase `json:"features"` + MetricThresholds []DataDriftMetricThresholdBase `json:"metricThresholds"` + ProductionData MonitoringInputDataBase `json:"productionData"` + ReferenceData MonitoringInputDataBase `json:"referenceData"` + + // Fields inherited from MonitoringSignalBase + + NotificationTypes *[]MonitoringNotificationType `json:"notificationTypes,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + SignalType MonitoringSignalType `json:"signalType"` +} + +func (s DataDriftMonitoringSignal) MonitoringSignalBase() BaseMonitoringSignalBaseImpl { + return BaseMonitoringSignalBaseImpl{ + NotificationTypes: s.NotificationTypes, + Properties: s.Properties, + SignalType: s.SignalType, + } +} + +var _ json.Marshaler = DataDriftMonitoringSignal{} + +func (s DataDriftMonitoringSignal) MarshalJSON() ([]byte, error) { + type wrapper DataDriftMonitoringSignal + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DataDriftMonitoringSignal: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DataDriftMonitoringSignal: %+v", err) + } + + decoded["signalType"] = "DataDrift" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DataDriftMonitoringSignal: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &DataDriftMonitoringSignal{} + +func (s *DataDriftMonitoringSignal) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FeatureDataTypeOverride *map[string]MonitoringFeatureDataType `json:"featureDataTypeOverride,omitempty"` + FeatureImportanceSettings *FeatureImportanceSettings `json:"featureImportanceSettings,omitempty"` + NotificationTypes *[]MonitoringNotificationType `json:"notificationTypes,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + SignalType MonitoringSignalType `json:"signalType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FeatureDataTypeOverride = decoded.FeatureDataTypeOverride + s.FeatureImportanceSettings = decoded.FeatureImportanceSettings + s.NotificationTypes = decoded.NotificationTypes + s.Properties = decoded.Properties + s.SignalType = decoded.SignalType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling DataDriftMonitoringSignal into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["features"]; ok { + impl, err := UnmarshalMonitoringFeatureFilterBaseImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Features' for 'DataDriftMonitoringSignal': %+v", err) + } + s.Features = impl + } + + if v, ok := temp["metricThresholds"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling MetricThresholds into list []json.RawMessage: %+v", err) + } + + output := make([]DataDriftMetricThresholdBase, 0) + for i, val := range listTemp { + impl, err := UnmarshalDataDriftMetricThresholdBaseImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'MetricThresholds' for 'DataDriftMonitoringSignal': %+v", i, err) + } + output = append(output, impl) + } + s.MetricThresholds = output + } + + if v, ok := temp["productionData"]; ok { + impl, err := UnmarshalMonitoringInputDataBaseImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProductionData' for 'DataDriftMonitoringSignal': %+v", err) + } + s.ProductionData = impl + } + + if v, ok := temp["referenceData"]; ok { + impl, err := UnmarshalMonitoringInputDataBaseImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ReferenceData' for 'DataDriftMonitoringSignal': %+v", err) + } + s.ReferenceData = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_dataqualitymetricthresholdbase.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_dataqualitymetricthresholdbase.go new file mode 100644 index 00000000000..d1a858c0bcc --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_dataqualitymetricthresholdbase.go @@ -0,0 +1,84 @@ +package schedule + +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 DataQualityMetricThresholdBase interface { + DataQualityMetricThresholdBase() BaseDataQualityMetricThresholdBaseImpl +} + +var _ DataQualityMetricThresholdBase = BaseDataQualityMetricThresholdBaseImpl{} + +type BaseDataQualityMetricThresholdBaseImpl struct { + DataType MonitoringFeatureDataType `json:"dataType"` + Threshold *MonitoringThreshold `json:"threshold,omitempty"` +} + +func (s BaseDataQualityMetricThresholdBaseImpl) DataQualityMetricThresholdBase() BaseDataQualityMetricThresholdBaseImpl { + return s +} + +var _ DataQualityMetricThresholdBase = RawDataQualityMetricThresholdBaseImpl{} + +// RawDataQualityMetricThresholdBaseImpl 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 RawDataQualityMetricThresholdBaseImpl struct { + dataQualityMetricThresholdBase BaseDataQualityMetricThresholdBaseImpl + Type string + Values map[string]interface{} +} + +func (s RawDataQualityMetricThresholdBaseImpl) DataQualityMetricThresholdBase() BaseDataQualityMetricThresholdBaseImpl { + return s.dataQualityMetricThresholdBase +} + +func UnmarshalDataQualityMetricThresholdBaseImplementation(input []byte) (DataQualityMetricThresholdBase, 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 DataQualityMetricThresholdBase into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["dataType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Categorical") { + var out CategoricalDataQualityMetricThreshold + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CategoricalDataQualityMetricThreshold: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Numerical") { + var out NumericalDataQualityMetricThreshold + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into NumericalDataQualityMetricThreshold: %+v", err) + } + return out, nil + } + + var parent BaseDataQualityMetricThresholdBaseImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseDataQualityMetricThresholdBaseImpl: %+v", err) + } + + return RawDataQualityMetricThresholdBaseImpl{ + dataQualityMetricThresholdBase: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_dataqualitymonitoringsignal.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_dataqualitymonitoringsignal.go new file mode 100644 index 00000000000..014139febcd --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_dataqualitymonitoringsignal.go @@ -0,0 +1,128 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ MonitoringSignalBase = DataQualityMonitoringSignal{} + +type DataQualityMonitoringSignal struct { + FeatureDataTypeOverride *map[string]MonitoringFeatureDataType `json:"featureDataTypeOverride,omitempty"` + FeatureImportanceSettings *FeatureImportanceSettings `json:"featureImportanceSettings,omitempty"` + Features MonitoringFeatureFilterBase `json:"features"` + MetricThresholds []DataQualityMetricThresholdBase `json:"metricThresholds"` + ProductionData MonitoringInputDataBase `json:"productionData"` + ReferenceData MonitoringInputDataBase `json:"referenceData"` + + // Fields inherited from MonitoringSignalBase + + NotificationTypes *[]MonitoringNotificationType `json:"notificationTypes,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + SignalType MonitoringSignalType `json:"signalType"` +} + +func (s DataQualityMonitoringSignal) MonitoringSignalBase() BaseMonitoringSignalBaseImpl { + return BaseMonitoringSignalBaseImpl{ + NotificationTypes: s.NotificationTypes, + Properties: s.Properties, + SignalType: s.SignalType, + } +} + +var _ json.Marshaler = DataQualityMonitoringSignal{} + +func (s DataQualityMonitoringSignal) MarshalJSON() ([]byte, error) { + type wrapper DataQualityMonitoringSignal + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling DataQualityMonitoringSignal: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling DataQualityMonitoringSignal: %+v", err) + } + + decoded["signalType"] = "DataQuality" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling DataQualityMonitoringSignal: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &DataQualityMonitoringSignal{} + +func (s *DataQualityMonitoringSignal) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FeatureDataTypeOverride *map[string]MonitoringFeatureDataType `json:"featureDataTypeOverride,omitempty"` + FeatureImportanceSettings *FeatureImportanceSettings `json:"featureImportanceSettings,omitempty"` + NotificationTypes *[]MonitoringNotificationType `json:"notificationTypes,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + SignalType MonitoringSignalType `json:"signalType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FeatureDataTypeOverride = decoded.FeatureDataTypeOverride + s.FeatureImportanceSettings = decoded.FeatureImportanceSettings + s.NotificationTypes = decoded.NotificationTypes + s.Properties = decoded.Properties + s.SignalType = decoded.SignalType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling DataQualityMonitoringSignal into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["features"]; ok { + impl, err := UnmarshalMonitoringFeatureFilterBaseImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Features' for 'DataQualityMonitoringSignal': %+v", err) + } + s.Features = impl + } + + if v, ok := temp["metricThresholds"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling MetricThresholds into list []json.RawMessage: %+v", err) + } + + output := make([]DataQualityMetricThresholdBase, 0) + for i, val := range listTemp { + impl, err := UnmarshalDataQualityMetricThresholdBaseImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'MetricThresholds' for 'DataQualityMonitoringSignal': %+v", i, err) + } + output = append(output, impl) + } + s.MetricThresholds = output + } + + if v, ok := temp["productionData"]; ok { + impl, err := UnmarshalMonitoringInputDataBaseImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProductionData' for 'DataQualityMonitoringSignal': %+v", err) + } + s.ProductionData = impl + } + + if v, ok := temp["referenceData"]; ok { + impl, err := UnmarshalMonitoringInputDataBaseImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ReferenceData' for 'DataQualityMonitoringSignal': %+v", err) + } + s.ReferenceData = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_distributionconfiguration.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_distributionconfiguration.go new file mode 100644 index 00000000000..c5c8340a57f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_distributionconfiguration.go @@ -0,0 +1,91 @@ +package schedule + +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 DistributionConfiguration interface { + DistributionConfiguration() BaseDistributionConfigurationImpl +} + +var _ DistributionConfiguration = BaseDistributionConfigurationImpl{} + +type BaseDistributionConfigurationImpl struct { + DistributionType DistributionType `json:"distributionType"` +} + +func (s BaseDistributionConfigurationImpl) DistributionConfiguration() BaseDistributionConfigurationImpl { + return s +} + +var _ DistributionConfiguration = RawDistributionConfigurationImpl{} + +// RawDistributionConfigurationImpl 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 RawDistributionConfigurationImpl struct { + distributionConfiguration BaseDistributionConfigurationImpl + Type string + Values map[string]interface{} +} + +func (s RawDistributionConfigurationImpl) DistributionConfiguration() BaseDistributionConfigurationImpl { + return s.distributionConfiguration +} + +func UnmarshalDistributionConfigurationImplementation(input []byte) (DistributionConfiguration, 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 DistributionConfiguration into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["distributionType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Mpi") { + var out Mpi + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into Mpi: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "PyTorch") { + var out PyTorch + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into PyTorch: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "TensorFlow") { + var out TensorFlow + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into TensorFlow: %+v", err) + } + return out, nil + } + + var parent BaseDistributionConfigurationImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseDistributionConfigurationImpl: %+v", err) + } + + return RawDistributionConfigurationImpl{ + distributionConfiguration: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_earlyterminationpolicy.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_earlyterminationpolicy.go new file mode 100644 index 00000000000..ba6556ad8af --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_earlyterminationpolicy.go @@ -0,0 +1,93 @@ +package schedule + +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 EarlyTerminationPolicy interface { + EarlyTerminationPolicy() BaseEarlyTerminationPolicyImpl +} + +var _ EarlyTerminationPolicy = BaseEarlyTerminationPolicyImpl{} + +type BaseEarlyTerminationPolicyImpl struct { + DelayEvaluation *int64 `json:"delayEvaluation,omitempty"` + EvaluationInterval *int64 `json:"evaluationInterval,omitempty"` + PolicyType EarlyTerminationPolicyType `json:"policyType"` +} + +func (s BaseEarlyTerminationPolicyImpl) EarlyTerminationPolicy() BaseEarlyTerminationPolicyImpl { + return s +} + +var _ EarlyTerminationPolicy = RawEarlyTerminationPolicyImpl{} + +// RawEarlyTerminationPolicyImpl 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 RawEarlyTerminationPolicyImpl struct { + earlyTerminationPolicy BaseEarlyTerminationPolicyImpl + Type string + Values map[string]interface{} +} + +func (s RawEarlyTerminationPolicyImpl) EarlyTerminationPolicy() BaseEarlyTerminationPolicyImpl { + return s.earlyTerminationPolicy +} + +func UnmarshalEarlyTerminationPolicyImplementation(input []byte) (EarlyTerminationPolicy, 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 EarlyTerminationPolicy into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["policyType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Bandit") { + var out BanditPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into BanditPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "MedianStopping") { + var out MedianStoppingPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MedianStoppingPolicy: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "TruncationSelection") { + var out TruncationSelectionPolicy + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into TruncationSelectionPolicy: %+v", err) + } + return out, nil + } + + var parent BaseEarlyTerminationPolicyImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseEarlyTerminationPolicyImpl: %+v", err) + } + + return RawEarlyTerminationPolicyImpl{ + earlyTerminationPolicy: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_endpointscheduleaction.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_endpointscheduleaction.go new file mode 100644 index 00000000000..a50c708e732 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_endpointscheduleaction.go @@ -0,0 +1,50 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ScheduleActionBase = EndpointScheduleAction{} + +type EndpointScheduleAction struct { + EndpointInvocationDefinition interface{} `json:"endpointInvocationDefinition"` + + // Fields inherited from ScheduleActionBase + + ActionType ScheduleActionType `json:"actionType"` +} + +func (s EndpointScheduleAction) ScheduleActionBase() BaseScheduleActionBaseImpl { + return BaseScheduleActionBaseImpl{ + ActionType: s.ActionType, + } +} + +var _ json.Marshaler = EndpointScheduleAction{} + +func (s EndpointScheduleAction) MarshalJSON() ([]byte, error) { + type wrapper EndpointScheduleAction + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling EndpointScheduleAction: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling EndpointScheduleAction: %+v", err) + } + + decoded["actionType"] = "InvokeBatchEndpoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling EndpointScheduleAction: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_featureattributiondriftmonitoringsignal.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_featureattributiondriftmonitoringsignal.go new file mode 100644 index 00000000000..dde656890b5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_featureattributiondriftmonitoringsignal.go @@ -0,0 +1,113 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ MonitoringSignalBase = FeatureAttributionDriftMonitoringSignal{} + +type FeatureAttributionDriftMonitoringSignal struct { + FeatureDataTypeOverride *map[string]MonitoringFeatureDataType `json:"featureDataTypeOverride,omitempty"` + FeatureImportanceSettings FeatureImportanceSettings `json:"featureImportanceSettings"` + MetricThreshold FeatureAttributionMetricThreshold `json:"metricThreshold"` + ProductionData []MonitoringInputDataBase `json:"productionData"` + ReferenceData MonitoringInputDataBase `json:"referenceData"` + + // Fields inherited from MonitoringSignalBase + + NotificationTypes *[]MonitoringNotificationType `json:"notificationTypes,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + SignalType MonitoringSignalType `json:"signalType"` +} + +func (s FeatureAttributionDriftMonitoringSignal) MonitoringSignalBase() BaseMonitoringSignalBaseImpl { + return BaseMonitoringSignalBaseImpl{ + NotificationTypes: s.NotificationTypes, + Properties: s.Properties, + SignalType: s.SignalType, + } +} + +var _ json.Marshaler = FeatureAttributionDriftMonitoringSignal{} + +func (s FeatureAttributionDriftMonitoringSignal) MarshalJSON() ([]byte, error) { + type wrapper FeatureAttributionDriftMonitoringSignal + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling FeatureAttributionDriftMonitoringSignal: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling FeatureAttributionDriftMonitoringSignal: %+v", err) + } + + decoded["signalType"] = "FeatureAttributionDrift" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling FeatureAttributionDriftMonitoringSignal: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &FeatureAttributionDriftMonitoringSignal{} + +func (s *FeatureAttributionDriftMonitoringSignal) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FeatureDataTypeOverride *map[string]MonitoringFeatureDataType `json:"featureDataTypeOverride,omitempty"` + FeatureImportanceSettings FeatureImportanceSettings `json:"featureImportanceSettings"` + MetricThreshold FeatureAttributionMetricThreshold `json:"metricThreshold"` + NotificationTypes *[]MonitoringNotificationType `json:"notificationTypes,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + SignalType MonitoringSignalType `json:"signalType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FeatureDataTypeOverride = decoded.FeatureDataTypeOverride + s.FeatureImportanceSettings = decoded.FeatureImportanceSettings + s.MetricThreshold = decoded.MetricThreshold + s.NotificationTypes = decoded.NotificationTypes + s.Properties = decoded.Properties + s.SignalType = decoded.SignalType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling FeatureAttributionDriftMonitoringSignal into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["productionData"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling ProductionData into list []json.RawMessage: %+v", err) + } + + output := make([]MonitoringInputDataBase, 0) + for i, val := range listTemp { + impl, err := UnmarshalMonitoringInputDataBaseImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'ProductionData' for 'FeatureAttributionDriftMonitoringSignal': %+v", i, err) + } + output = append(output, impl) + } + s.ProductionData = output + } + + if v, ok := temp["referenceData"]; ok { + impl, err := UnmarshalMonitoringInputDataBaseImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ReferenceData' for 'FeatureAttributionDriftMonitoringSignal': %+v", err) + } + s.ReferenceData = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_featureattributionmetricthreshold.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_featureattributionmetricthreshold.go new file mode 100644 index 00000000000..3090a91687b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_featureattributionmetricthreshold.go @@ -0,0 +1,9 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FeatureAttributionMetricThreshold struct { + Metric FeatureAttributionMetric `json:"metric"` + Threshold *MonitoringThreshold `json:"threshold,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_featureimportancesettings.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_featureimportancesettings.go new file mode 100644 index 00000000000..6f3b49e9234 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_featureimportancesettings.go @@ -0,0 +1,9 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FeatureImportanceSettings struct { + Mode *FeatureImportanceMode `json:"mode,omitempty"` + TargetColumn *string `json:"targetColumn,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_featuresubset.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_featuresubset.go new file mode 100644 index 00000000000..8fdb9c9d2c3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_featuresubset.go @@ -0,0 +1,50 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ MonitoringFeatureFilterBase = FeatureSubset{} + +type FeatureSubset struct { + Features []string `json:"features"` + + // Fields inherited from MonitoringFeatureFilterBase + + FilterType MonitoringFeatureFilterType `json:"filterType"` +} + +func (s FeatureSubset) MonitoringFeatureFilterBase() BaseMonitoringFeatureFilterBaseImpl { + return BaseMonitoringFeatureFilterBaseImpl{ + FilterType: s.FilterType, + } +} + +var _ json.Marshaler = FeatureSubset{} + +func (s FeatureSubset) MarshalJSON() ([]byte, error) { + type wrapper FeatureSubset + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling FeatureSubset: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling FeatureSubset: %+v", err) + } + + decoded["filterType"] = "FeatureSubset" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling FeatureSubset: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_featurizationsettings.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_featurizationsettings.go new file mode 100644 index 00000000000..2e9b9e16c23 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_featurizationsettings.go @@ -0,0 +1,8 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FeaturizationSettings struct { + DatasetLanguage *string `json:"datasetLanguage,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_fixedinputdata.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_fixedinputdata.go new file mode 100644 index 00000000000..9c388f512ef --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_fixedinputdata.go @@ -0,0 +1,57 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ MonitoringInputDataBase = FixedInputData{} + +type FixedInputData struct { + + // Fields inherited from MonitoringInputDataBase + + Columns *map[string]string `json:"columns,omitempty"` + DataContext *string `json:"dataContext,omitempty"` + InputDataType MonitoringInputDataType `json:"inputDataType"` + JobInputType JobInputType `json:"jobInputType"` + Uri string `json:"uri"` +} + +func (s FixedInputData) MonitoringInputDataBase() BaseMonitoringInputDataBaseImpl { + return BaseMonitoringInputDataBaseImpl{ + Columns: s.Columns, + DataContext: s.DataContext, + InputDataType: s.InputDataType, + JobInputType: s.JobInputType, + Uri: s.Uri, + } +} + +var _ json.Marshaler = FixedInputData{} + +func (s FixedInputData) MarshalJSON() ([]byte, error) { + type wrapper FixedInputData + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling FixedInputData: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling FixedInputData: %+v", err) + } + + decoded["inputDataType"] = "Fixed" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling FixedInputData: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_forecasthorizon.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_forecasthorizon.go new file mode 100644 index 00000000000..e9ee3c3f112 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_forecasthorizon.go @@ -0,0 +1,83 @@ +package schedule + +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 ForecastHorizon interface { + ForecastHorizon() BaseForecastHorizonImpl +} + +var _ ForecastHorizon = BaseForecastHorizonImpl{} + +type BaseForecastHorizonImpl struct { + Mode ForecastHorizonMode `json:"mode"` +} + +func (s BaseForecastHorizonImpl) ForecastHorizon() BaseForecastHorizonImpl { + return s +} + +var _ ForecastHorizon = RawForecastHorizonImpl{} + +// RawForecastHorizonImpl 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 RawForecastHorizonImpl struct { + forecastHorizon BaseForecastHorizonImpl + Type string + Values map[string]interface{} +} + +func (s RawForecastHorizonImpl) ForecastHorizon() BaseForecastHorizonImpl { + return s.forecastHorizon +} + +func UnmarshalForecastHorizonImplementation(input []byte) (ForecastHorizon, 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 ForecastHorizon into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["mode"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Auto") { + var out AutoForecastHorizon + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AutoForecastHorizon: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Custom") { + var out CustomForecastHorizon + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CustomForecastHorizon: %+v", err) + } + return out, nil + } + + var parent BaseForecastHorizonImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseForecastHorizonImpl: %+v", err) + } + + return RawForecastHorizonImpl{ + forecastHorizon: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_forecasting.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_forecasting.go new file mode 100644 index 00000000000..a36dac2803b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_forecasting.go @@ -0,0 +1,123 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AutoMLVertical = Forecasting{} + +type Forecasting struct { + CvSplitColumnNames *[]string `json:"cvSplitColumnNames,omitempty"` + FeaturizationSettings *TableVerticalFeaturizationSettings `json:"featurizationSettings,omitempty"` + ForecastingSettings *ForecastingSettings `json:"forecastingSettings,omitempty"` + LimitSettings *TableVerticalLimitSettings `json:"limitSettings,omitempty"` + NCrossValidations NCrossValidations `json:"nCrossValidations"` + PrimaryMetric *ForecastingPrimaryMetrics `json:"primaryMetric,omitempty"` + TestData *MLTableJobInput `json:"testData,omitempty"` + TestDataSize *float64 `json:"testDataSize,omitempty"` + TrainingSettings *ForecastingTrainingSettings `json:"trainingSettings,omitempty"` + ValidationData *MLTableJobInput `json:"validationData,omitempty"` + ValidationDataSize *float64 `json:"validationDataSize,omitempty"` + WeightColumnName *string `json:"weightColumnName,omitempty"` + + // Fields inherited from AutoMLVertical + + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` +} + +func (s Forecasting) AutoMLVertical() BaseAutoMLVerticalImpl { + return BaseAutoMLVerticalImpl{ + LogVerbosity: s.LogVerbosity, + TargetColumnName: s.TargetColumnName, + TaskType: s.TaskType, + TrainingData: s.TrainingData, + } +} + +var _ json.Marshaler = Forecasting{} + +func (s Forecasting) MarshalJSON() ([]byte, error) { + type wrapper Forecasting + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling Forecasting: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling Forecasting: %+v", err) + } + + decoded["taskType"] = "Forecasting" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling Forecasting: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &Forecasting{} + +func (s *Forecasting) UnmarshalJSON(bytes []byte) error { + var decoded struct { + CvSplitColumnNames *[]string `json:"cvSplitColumnNames,omitempty"` + FeaturizationSettings *TableVerticalFeaturizationSettings `json:"featurizationSettings,omitempty"` + ForecastingSettings *ForecastingSettings `json:"forecastingSettings,omitempty"` + LimitSettings *TableVerticalLimitSettings `json:"limitSettings,omitempty"` + PrimaryMetric *ForecastingPrimaryMetrics `json:"primaryMetric,omitempty"` + TestData *MLTableJobInput `json:"testData,omitempty"` + TestDataSize *float64 `json:"testDataSize,omitempty"` + TrainingSettings *ForecastingTrainingSettings `json:"trainingSettings,omitempty"` + ValidationData *MLTableJobInput `json:"validationData,omitempty"` + ValidationDataSize *float64 `json:"validationDataSize,omitempty"` + WeightColumnName *string `json:"weightColumnName,omitempty"` + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.CvSplitColumnNames = decoded.CvSplitColumnNames + s.FeaturizationSettings = decoded.FeaturizationSettings + s.ForecastingSettings = decoded.ForecastingSettings + s.LimitSettings = decoded.LimitSettings + s.PrimaryMetric = decoded.PrimaryMetric + s.TestData = decoded.TestData + s.TestDataSize = decoded.TestDataSize + s.TrainingSettings = decoded.TrainingSettings + s.ValidationData = decoded.ValidationData + s.ValidationDataSize = decoded.ValidationDataSize + s.WeightColumnName = decoded.WeightColumnName + s.LogVerbosity = decoded.LogVerbosity + s.TargetColumnName = decoded.TargetColumnName + s.TaskType = decoded.TaskType + s.TrainingData = decoded.TrainingData + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling Forecasting into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["nCrossValidations"]; ok { + impl, err := UnmarshalNCrossValidationsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'NCrossValidations' for 'Forecasting': %+v", err) + } + s.NCrossValidations = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_forecastingsettings.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_forecastingsettings.go new file mode 100644 index 00000000000..343841991d2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_forecastingsettings.go @@ -0,0 +1,93 @@ +package schedule + +import ( + "encoding/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 ForecastingSettings struct { + CountryOrRegionForHolidays *string `json:"countryOrRegionForHolidays,omitempty"` + CvStepSize *int64 `json:"cvStepSize,omitempty"` + FeatureLags *FeatureLags `json:"featureLags,omitempty"` + ForecastHorizon ForecastHorizon `json:"forecastHorizon"` + Frequency *string `json:"frequency,omitempty"` + Seasonality Seasonality `json:"seasonality"` + ShortSeriesHandlingConfig *ShortSeriesHandlingConfiguration `json:"shortSeriesHandlingConfig,omitempty"` + TargetAggregateFunction *TargetAggregationFunction `json:"targetAggregateFunction,omitempty"` + TargetLags TargetLags `json:"targetLags"` + TargetRollingWindowSize TargetRollingWindowSize `json:"targetRollingWindowSize"` + TimeColumnName *string `json:"timeColumnName,omitempty"` + TimeSeriesIdColumnNames *[]string `json:"timeSeriesIdColumnNames,omitempty"` + UseStl *UseStl `json:"useStl,omitempty"` +} + +var _ json.Unmarshaler = &ForecastingSettings{} + +func (s *ForecastingSettings) UnmarshalJSON(bytes []byte) error { + var decoded struct { + CountryOrRegionForHolidays *string `json:"countryOrRegionForHolidays,omitempty"` + CvStepSize *int64 `json:"cvStepSize,omitempty"` + FeatureLags *FeatureLags `json:"featureLags,omitempty"` + Frequency *string `json:"frequency,omitempty"` + ShortSeriesHandlingConfig *ShortSeriesHandlingConfiguration `json:"shortSeriesHandlingConfig,omitempty"` + TargetAggregateFunction *TargetAggregationFunction `json:"targetAggregateFunction,omitempty"` + TimeColumnName *string `json:"timeColumnName,omitempty"` + TimeSeriesIdColumnNames *[]string `json:"timeSeriesIdColumnNames,omitempty"` + UseStl *UseStl `json:"useStl,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.CountryOrRegionForHolidays = decoded.CountryOrRegionForHolidays + s.CvStepSize = decoded.CvStepSize + s.FeatureLags = decoded.FeatureLags + s.Frequency = decoded.Frequency + s.ShortSeriesHandlingConfig = decoded.ShortSeriesHandlingConfig + s.TargetAggregateFunction = decoded.TargetAggregateFunction + s.TimeColumnName = decoded.TimeColumnName + s.TimeSeriesIdColumnNames = decoded.TimeSeriesIdColumnNames + s.UseStl = decoded.UseStl + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ForecastingSettings into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["forecastHorizon"]; ok { + impl, err := UnmarshalForecastHorizonImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ForecastHorizon' for 'ForecastingSettings': %+v", err) + } + s.ForecastHorizon = impl + } + + if v, ok := temp["seasonality"]; ok { + impl, err := UnmarshalSeasonalityImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Seasonality' for 'ForecastingSettings': %+v", err) + } + s.Seasonality = impl + } + + if v, ok := temp["targetLags"]; ok { + impl, err := UnmarshalTargetLagsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'TargetLags' for 'ForecastingSettings': %+v", err) + } + s.TargetLags = impl + } + + if v, ok := temp["targetRollingWindowSize"]; ok { + impl, err := UnmarshalTargetRollingWindowSizeImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'TargetRollingWindowSize' for 'ForecastingSettings': %+v", err) + } + s.TargetRollingWindowSize = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_forecastingtrainingsettings.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_forecastingtrainingsettings.go new file mode 100644 index 00000000000..dd874bba18b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_forecastingtrainingsettings.go @@ -0,0 +1,16 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ForecastingTrainingSettings struct { + AllowedTrainingAlgorithms *[]ForecastingModels `json:"allowedTrainingAlgorithms,omitempty"` + BlockedTrainingAlgorithms *[]ForecastingModels `json:"blockedTrainingAlgorithms,omitempty"` + EnableDnnTraining *bool `json:"enableDnnTraining,omitempty"` + EnableModelExplainability *bool `json:"enableModelExplainability,omitempty"` + EnableOnnxCompatibleModels *bool `json:"enableOnnxCompatibleModels,omitempty"` + EnableStackEnsemble *bool `json:"enableStackEnsemble,omitempty"` + EnableVoteEnsemble *bool `json:"enableVoteEnsemble,omitempty"` + EnsembleModelDownloadTimeout *string `json:"ensembleModelDownloadTimeout,omitempty"` + StackEnsembleSettings *StackEnsembleSettings `json:"stackEnsembleSettings,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_gridsamplingalgorithm.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_gridsamplingalgorithm.go new file mode 100644 index 00000000000..b577ac63c96 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_gridsamplingalgorithm.go @@ -0,0 +1,49 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SamplingAlgorithm = GridSamplingAlgorithm{} + +type GridSamplingAlgorithm struct { + + // Fields inherited from SamplingAlgorithm + + SamplingAlgorithmType SamplingAlgorithmType `json:"samplingAlgorithmType"` +} + +func (s GridSamplingAlgorithm) SamplingAlgorithm() BaseSamplingAlgorithmImpl { + return BaseSamplingAlgorithmImpl{ + SamplingAlgorithmType: s.SamplingAlgorithmType, + } +} + +var _ json.Marshaler = GridSamplingAlgorithm{} + +func (s GridSamplingAlgorithm) MarshalJSON() ([]byte, error) { + type wrapper GridSamplingAlgorithm + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling GridSamplingAlgorithm: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling GridSamplingAlgorithm: %+v", err) + } + + decoded["samplingAlgorithmType"] = "Grid" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling GridSamplingAlgorithm: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_identityconfiguration.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_identityconfiguration.go new file mode 100644 index 00000000000..d12129e53de --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_identityconfiguration.go @@ -0,0 +1,91 @@ +package schedule + +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 IdentityConfiguration interface { + IdentityConfiguration() BaseIdentityConfigurationImpl +} + +var _ IdentityConfiguration = BaseIdentityConfigurationImpl{} + +type BaseIdentityConfigurationImpl struct { + IdentityType IdentityConfigurationType `json:"identityType"` +} + +func (s BaseIdentityConfigurationImpl) IdentityConfiguration() BaseIdentityConfigurationImpl { + return s +} + +var _ IdentityConfiguration = RawIdentityConfigurationImpl{} + +// RawIdentityConfigurationImpl 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 RawIdentityConfigurationImpl struct { + identityConfiguration BaseIdentityConfigurationImpl + Type string + Values map[string]interface{} +} + +func (s RawIdentityConfigurationImpl) IdentityConfiguration() BaseIdentityConfigurationImpl { + return s.identityConfiguration +} + +func UnmarshalIdentityConfigurationImplementation(input []byte) (IdentityConfiguration, 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 IdentityConfiguration into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["identityType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AMLToken") { + var out AmlToken + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AmlToken: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Managed") { + var out ManagedIdentity + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ManagedIdentity: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "UserIdentity") { + var out UserIdentity + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into UserIdentity: %+v", err) + } + return out, nil + } + + var parent BaseIdentityConfigurationImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseIdentityConfigurationImpl: %+v", err) + } + + return RawIdentityConfigurationImpl{ + identityConfiguration: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_imageclassification.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_imageclassification.go new file mode 100644 index 00000000000..50d25482a05 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_imageclassification.go @@ -0,0 +1,62 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AutoMLVertical = ImageClassification{} + +type ImageClassification struct { + LimitSettings ImageLimitSettings `json:"limitSettings"` + ModelSettings *ImageModelSettingsClassification `json:"modelSettings,omitempty"` + PrimaryMetric *ClassificationPrimaryMetrics `json:"primaryMetric,omitempty"` + SearchSpace *[]ImageModelDistributionSettingsClassification `json:"searchSpace,omitempty"` + SweepSettings *ImageSweepSettings `json:"sweepSettings,omitempty"` + ValidationData *MLTableJobInput `json:"validationData,omitempty"` + ValidationDataSize *float64 `json:"validationDataSize,omitempty"` + + // Fields inherited from AutoMLVertical + + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` +} + +func (s ImageClassification) AutoMLVertical() BaseAutoMLVerticalImpl { + return BaseAutoMLVerticalImpl{ + LogVerbosity: s.LogVerbosity, + TargetColumnName: s.TargetColumnName, + TaskType: s.TaskType, + TrainingData: s.TrainingData, + } +} + +var _ json.Marshaler = ImageClassification{} + +func (s ImageClassification) MarshalJSON() ([]byte, error) { + type wrapper ImageClassification + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ImageClassification: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ImageClassification: %+v", err) + } + + decoded["taskType"] = "ImageClassification" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ImageClassification: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_imageclassificationmultilabel.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_imageclassificationmultilabel.go new file mode 100644 index 00000000000..315c759395b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_imageclassificationmultilabel.go @@ -0,0 +1,62 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AutoMLVertical = ImageClassificationMultilabel{} + +type ImageClassificationMultilabel struct { + LimitSettings ImageLimitSettings `json:"limitSettings"` + ModelSettings *ImageModelSettingsClassification `json:"modelSettings,omitempty"` + PrimaryMetric *ClassificationMultilabelPrimaryMetrics `json:"primaryMetric,omitempty"` + SearchSpace *[]ImageModelDistributionSettingsClassification `json:"searchSpace,omitempty"` + SweepSettings *ImageSweepSettings `json:"sweepSettings,omitempty"` + ValidationData *MLTableJobInput `json:"validationData,omitempty"` + ValidationDataSize *float64 `json:"validationDataSize,omitempty"` + + // Fields inherited from AutoMLVertical + + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` +} + +func (s ImageClassificationMultilabel) AutoMLVertical() BaseAutoMLVerticalImpl { + return BaseAutoMLVerticalImpl{ + LogVerbosity: s.LogVerbosity, + TargetColumnName: s.TargetColumnName, + TaskType: s.TaskType, + TrainingData: s.TrainingData, + } +} + +var _ json.Marshaler = ImageClassificationMultilabel{} + +func (s ImageClassificationMultilabel) MarshalJSON() ([]byte, error) { + type wrapper ImageClassificationMultilabel + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ImageClassificationMultilabel: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ImageClassificationMultilabel: %+v", err) + } + + decoded["taskType"] = "ImageClassificationMultilabel" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ImageClassificationMultilabel: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_imageinstancesegmentation.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_imageinstancesegmentation.go new file mode 100644 index 00000000000..678a4359ec9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_imageinstancesegmentation.go @@ -0,0 +1,62 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AutoMLVertical = ImageInstanceSegmentation{} + +type ImageInstanceSegmentation struct { + LimitSettings ImageLimitSettings `json:"limitSettings"` + ModelSettings *ImageModelSettingsObjectDetection `json:"modelSettings,omitempty"` + PrimaryMetric *InstanceSegmentationPrimaryMetrics `json:"primaryMetric,omitempty"` + SearchSpace *[]ImageModelDistributionSettingsObjectDetection `json:"searchSpace,omitempty"` + SweepSettings *ImageSweepSettings `json:"sweepSettings,omitempty"` + ValidationData *MLTableJobInput `json:"validationData,omitempty"` + ValidationDataSize *float64 `json:"validationDataSize,omitempty"` + + // Fields inherited from AutoMLVertical + + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` +} + +func (s ImageInstanceSegmentation) AutoMLVertical() BaseAutoMLVerticalImpl { + return BaseAutoMLVerticalImpl{ + LogVerbosity: s.LogVerbosity, + TargetColumnName: s.TargetColumnName, + TaskType: s.TaskType, + TrainingData: s.TrainingData, + } +} + +var _ json.Marshaler = ImageInstanceSegmentation{} + +func (s ImageInstanceSegmentation) MarshalJSON() ([]byte, error) { + type wrapper ImageInstanceSegmentation + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ImageInstanceSegmentation: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ImageInstanceSegmentation: %+v", err) + } + + decoded["taskType"] = "ImageInstanceSegmentation" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ImageInstanceSegmentation: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_imagelimitsettings.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_imagelimitsettings.go new file mode 100644 index 00000000000..1e05d4de86a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_imagelimitsettings.go @@ -0,0 +1,10 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImageLimitSettings struct { + MaxConcurrentTrials *int64 `json:"maxConcurrentTrials,omitempty"` + MaxTrials *int64 `json:"maxTrials,omitempty"` + Timeout *string `json:"timeout,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_imagemodeldistributionsettingsclassification.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_imagemodeldistributionsettingsclassification.go new file mode 100644 index 00000000000..76fd1435bb7 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_imagemodeldistributionsettingsclassification.go @@ -0,0 +1,39 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImageModelDistributionSettingsClassification struct { + AmsGradient *string `json:"amsGradient,omitempty"` + Augmentations *string `json:"augmentations,omitempty"` + Beta1 *string `json:"beta1,omitempty"` + Beta2 *string `json:"beta2,omitempty"` + Distributed *string `json:"distributed,omitempty"` + EarlyStopping *string `json:"earlyStopping,omitempty"` + EarlyStoppingDelay *string `json:"earlyStoppingDelay,omitempty"` + EarlyStoppingPatience *string `json:"earlyStoppingPatience,omitempty"` + EnableOnnxNormalization *string `json:"enableOnnxNormalization,omitempty"` + EvaluationFrequency *string `json:"evaluationFrequency,omitempty"` + GradientAccumulationStep *string `json:"gradientAccumulationStep,omitempty"` + LayersToFreeze *string `json:"layersToFreeze,omitempty"` + LearningRate *string `json:"learningRate,omitempty"` + LearningRateScheduler *string `json:"learningRateScheduler,omitempty"` + ModelName *string `json:"modelName,omitempty"` + Momentum *string `json:"momentum,omitempty"` + Nesterov *string `json:"nesterov,omitempty"` + NumberOfEpochs *string `json:"numberOfEpochs,omitempty"` + NumberOfWorkers *string `json:"numberOfWorkers,omitempty"` + Optimizer *string `json:"optimizer,omitempty"` + RandomSeed *string `json:"randomSeed,omitempty"` + StepLRGamma *string `json:"stepLRGamma,omitempty"` + StepLRStepSize *string `json:"stepLRStepSize,omitempty"` + TrainingBatchSize *string `json:"trainingBatchSize,omitempty"` + TrainingCropSize *string `json:"trainingCropSize,omitempty"` + ValidationBatchSize *string `json:"validationBatchSize,omitempty"` + ValidationCropSize *string `json:"validationCropSize,omitempty"` + ValidationResizeSize *string `json:"validationResizeSize,omitempty"` + WarmupCosineLRCycles *string `json:"warmupCosineLRCycles,omitempty"` + WarmupCosineLRWarmupEpochs *string `json:"warmupCosineLRWarmupEpochs,omitempty"` + WeightDecay *string `json:"weightDecay,omitempty"` + WeightedLoss *string `json:"weightedLoss,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_imagemodeldistributionsettingsobjectdetection.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_imagemodeldistributionsettingsobjectdetection.go new file mode 100644 index 00000000000..b82d51837f8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_imagemodeldistributionsettingsobjectdetection.go @@ -0,0 +1,48 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImageModelDistributionSettingsObjectDetection struct { + AmsGradient *string `json:"amsGradient,omitempty"` + Augmentations *string `json:"augmentations,omitempty"` + Beta1 *string `json:"beta1,omitempty"` + Beta2 *string `json:"beta2,omitempty"` + BoxDetectionsPerImage *string `json:"boxDetectionsPerImage,omitempty"` + BoxScoreThreshold *string `json:"boxScoreThreshold,omitempty"` + Distributed *string `json:"distributed,omitempty"` + EarlyStopping *string `json:"earlyStopping,omitempty"` + EarlyStoppingDelay *string `json:"earlyStoppingDelay,omitempty"` + EarlyStoppingPatience *string `json:"earlyStoppingPatience,omitempty"` + EnableOnnxNormalization *string `json:"enableOnnxNormalization,omitempty"` + EvaluationFrequency *string `json:"evaluationFrequency,omitempty"` + GradientAccumulationStep *string `json:"gradientAccumulationStep,omitempty"` + ImageSize *string `json:"imageSize,omitempty"` + LayersToFreeze *string `json:"layersToFreeze,omitempty"` + LearningRate *string `json:"learningRate,omitempty"` + LearningRateScheduler *string `json:"learningRateScheduler,omitempty"` + MaxSize *string `json:"maxSize,omitempty"` + MinSize *string `json:"minSize,omitempty"` + ModelName *string `json:"modelName,omitempty"` + ModelSize *string `json:"modelSize,omitempty"` + Momentum *string `json:"momentum,omitempty"` + MultiScale *string `json:"multiScale,omitempty"` + Nesterov *string `json:"nesterov,omitempty"` + NmsIouThreshold *string `json:"nmsIouThreshold,omitempty"` + NumberOfEpochs *string `json:"numberOfEpochs,omitempty"` + NumberOfWorkers *string `json:"numberOfWorkers,omitempty"` + Optimizer *string `json:"optimizer,omitempty"` + RandomSeed *string `json:"randomSeed,omitempty"` + StepLRGamma *string `json:"stepLRGamma,omitempty"` + StepLRStepSize *string `json:"stepLRStepSize,omitempty"` + TileGridSize *string `json:"tileGridSize,omitempty"` + TileOverlapRatio *string `json:"tileOverlapRatio,omitempty"` + TilePredictionsNmsThreshold *string `json:"tilePredictionsNmsThreshold,omitempty"` + TrainingBatchSize *string `json:"trainingBatchSize,omitempty"` + ValidationBatchSize *string `json:"validationBatchSize,omitempty"` + ValidationIouThreshold *string `json:"validationIouThreshold,omitempty"` + ValidationMetricType *string `json:"validationMetricType,omitempty"` + WarmupCosineLRCycles *string `json:"warmupCosineLRCycles,omitempty"` + WarmupCosineLRWarmupEpochs *string `json:"warmupCosineLRWarmupEpochs,omitempty"` + WeightDecay *string `json:"weightDecay,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_imagemodelsettingsclassification.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_imagemodelsettingsclassification.go new file mode 100644 index 00000000000..b119aa98f75 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_imagemodelsettingsclassification.go @@ -0,0 +1,43 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImageModelSettingsClassification struct { + AdvancedSettings *string `json:"advancedSettings,omitempty"` + AmsGradient *bool `json:"amsGradient,omitempty"` + Augmentations *string `json:"augmentations,omitempty"` + Beta1 *float64 `json:"beta1,omitempty"` + Beta2 *float64 `json:"beta2,omitempty"` + CheckpointFrequency *int64 `json:"checkpointFrequency,omitempty"` + CheckpointModel *MLFlowModelJobInput `json:"checkpointModel,omitempty"` + CheckpointRunId *string `json:"checkpointRunId,omitempty"` + Distributed *bool `json:"distributed,omitempty"` + EarlyStopping *bool `json:"earlyStopping,omitempty"` + EarlyStoppingDelay *int64 `json:"earlyStoppingDelay,omitempty"` + EarlyStoppingPatience *int64 `json:"earlyStoppingPatience,omitempty"` + EnableOnnxNormalization *bool `json:"enableOnnxNormalization,omitempty"` + EvaluationFrequency *int64 `json:"evaluationFrequency,omitempty"` + GradientAccumulationStep *int64 `json:"gradientAccumulationStep,omitempty"` + LayersToFreeze *int64 `json:"layersToFreeze,omitempty"` + LearningRate *float64 `json:"learningRate,omitempty"` + LearningRateScheduler *LearningRateScheduler `json:"learningRateScheduler,omitempty"` + ModelName *string `json:"modelName,omitempty"` + Momentum *float64 `json:"momentum,omitempty"` + Nesterov *bool `json:"nesterov,omitempty"` + NumberOfEpochs *int64 `json:"numberOfEpochs,omitempty"` + NumberOfWorkers *int64 `json:"numberOfWorkers,omitempty"` + Optimizer *StochasticOptimizer `json:"optimizer,omitempty"` + RandomSeed *int64 `json:"randomSeed,omitempty"` + StepLRGamma *float64 `json:"stepLRGamma,omitempty"` + StepLRStepSize *int64 `json:"stepLRStepSize,omitempty"` + TrainingBatchSize *int64 `json:"trainingBatchSize,omitempty"` + TrainingCropSize *int64 `json:"trainingCropSize,omitempty"` + ValidationBatchSize *int64 `json:"validationBatchSize,omitempty"` + ValidationCropSize *int64 `json:"validationCropSize,omitempty"` + ValidationResizeSize *int64 `json:"validationResizeSize,omitempty"` + WarmupCosineLRCycles *float64 `json:"warmupCosineLRCycles,omitempty"` + WarmupCosineLRWarmupEpochs *int64 `json:"warmupCosineLRWarmupEpochs,omitempty"` + WeightDecay *float64 `json:"weightDecay,omitempty"` + WeightedLoss *int64 `json:"weightedLoss,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_imagemodelsettingsobjectdetection.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_imagemodelsettingsobjectdetection.go new file mode 100644 index 00000000000..44c887ac9dc --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_imagemodelsettingsobjectdetection.go @@ -0,0 +1,52 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ImageModelSettingsObjectDetection struct { + AdvancedSettings *string `json:"advancedSettings,omitempty"` + AmsGradient *bool `json:"amsGradient,omitempty"` + Augmentations *string `json:"augmentations,omitempty"` + Beta1 *float64 `json:"beta1,omitempty"` + Beta2 *float64 `json:"beta2,omitempty"` + BoxDetectionsPerImage *int64 `json:"boxDetectionsPerImage,omitempty"` + BoxScoreThreshold *float64 `json:"boxScoreThreshold,omitempty"` + CheckpointFrequency *int64 `json:"checkpointFrequency,omitempty"` + CheckpointModel *MLFlowModelJobInput `json:"checkpointModel,omitempty"` + CheckpointRunId *string `json:"checkpointRunId,omitempty"` + Distributed *bool `json:"distributed,omitempty"` + EarlyStopping *bool `json:"earlyStopping,omitempty"` + EarlyStoppingDelay *int64 `json:"earlyStoppingDelay,omitempty"` + EarlyStoppingPatience *int64 `json:"earlyStoppingPatience,omitempty"` + EnableOnnxNormalization *bool `json:"enableOnnxNormalization,omitempty"` + EvaluationFrequency *int64 `json:"evaluationFrequency,omitempty"` + GradientAccumulationStep *int64 `json:"gradientAccumulationStep,omitempty"` + ImageSize *int64 `json:"imageSize,omitempty"` + LayersToFreeze *int64 `json:"layersToFreeze,omitempty"` + LearningRate *float64 `json:"learningRate,omitempty"` + LearningRateScheduler *LearningRateScheduler `json:"learningRateScheduler,omitempty"` + MaxSize *int64 `json:"maxSize,omitempty"` + MinSize *int64 `json:"minSize,omitempty"` + ModelName *string `json:"modelName,omitempty"` + ModelSize *ModelSize `json:"modelSize,omitempty"` + Momentum *float64 `json:"momentum,omitempty"` + MultiScale *bool `json:"multiScale,omitempty"` + Nesterov *bool `json:"nesterov,omitempty"` + NmsIouThreshold *float64 `json:"nmsIouThreshold,omitempty"` + NumberOfEpochs *int64 `json:"numberOfEpochs,omitempty"` + NumberOfWorkers *int64 `json:"numberOfWorkers,omitempty"` + Optimizer *StochasticOptimizer `json:"optimizer,omitempty"` + RandomSeed *int64 `json:"randomSeed,omitempty"` + StepLRGamma *float64 `json:"stepLRGamma,omitempty"` + StepLRStepSize *int64 `json:"stepLRStepSize,omitempty"` + TileGridSize *string `json:"tileGridSize,omitempty"` + TileOverlapRatio *float64 `json:"tileOverlapRatio,omitempty"` + TilePredictionsNmsThreshold *float64 `json:"tilePredictionsNmsThreshold,omitempty"` + TrainingBatchSize *int64 `json:"trainingBatchSize,omitempty"` + ValidationBatchSize *int64 `json:"validationBatchSize,omitempty"` + ValidationIouThreshold *float64 `json:"validationIouThreshold,omitempty"` + ValidationMetricType *ValidationMetricType `json:"validationMetricType,omitempty"` + WarmupCosineLRCycles *float64 `json:"warmupCosineLRCycles,omitempty"` + WarmupCosineLRWarmupEpochs *int64 `json:"warmupCosineLRWarmupEpochs,omitempty"` + WeightDecay *float64 `json:"weightDecay,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_imageobjectdetection.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_imageobjectdetection.go new file mode 100644 index 00000000000..7849132338d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_imageobjectdetection.go @@ -0,0 +1,62 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AutoMLVertical = ImageObjectDetection{} + +type ImageObjectDetection struct { + LimitSettings ImageLimitSettings `json:"limitSettings"` + ModelSettings *ImageModelSettingsObjectDetection `json:"modelSettings,omitempty"` + PrimaryMetric *ObjectDetectionPrimaryMetrics `json:"primaryMetric,omitempty"` + SearchSpace *[]ImageModelDistributionSettingsObjectDetection `json:"searchSpace,omitempty"` + SweepSettings *ImageSweepSettings `json:"sweepSettings,omitempty"` + ValidationData *MLTableJobInput `json:"validationData,omitempty"` + ValidationDataSize *float64 `json:"validationDataSize,omitempty"` + + // Fields inherited from AutoMLVertical + + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` +} + +func (s ImageObjectDetection) AutoMLVertical() BaseAutoMLVerticalImpl { + return BaseAutoMLVerticalImpl{ + LogVerbosity: s.LogVerbosity, + TargetColumnName: s.TargetColumnName, + TaskType: s.TaskType, + TrainingData: s.TrainingData, + } +} + +var _ json.Marshaler = ImageObjectDetection{} + +func (s ImageObjectDetection) MarshalJSON() ([]byte, error) { + type wrapper ImageObjectDetection + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ImageObjectDetection: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ImageObjectDetection: %+v", err) + } + + decoded["taskType"] = "ImageObjectDetection" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ImageObjectDetection: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_imagesweepsettings.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_imagesweepsettings.go new file mode 100644 index 00000000000..8b6b8d54aad --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_imagesweepsettings.go @@ -0,0 +1,42 @@ +package schedule + +import ( + "encoding/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 ImageSweepSettings struct { + EarlyTermination EarlyTerminationPolicy `json:"earlyTermination"` + SamplingAlgorithm SamplingAlgorithmType `json:"samplingAlgorithm"` +} + +var _ json.Unmarshaler = &ImageSweepSettings{} + +func (s *ImageSweepSettings) UnmarshalJSON(bytes []byte) error { + var decoded struct { + SamplingAlgorithm SamplingAlgorithmType `json:"samplingAlgorithm"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.SamplingAlgorithm = decoded.SamplingAlgorithm + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ImageSweepSettings into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["earlyTermination"]; ok { + impl, err := UnmarshalEarlyTerminationPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'EarlyTermination' for 'ImageSweepSettings': %+v", err) + } + s.EarlyTermination = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_jobbase.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_jobbase.go new file mode 100644 index 00000000000..fdeb6956fd1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_jobbase.go @@ -0,0 +1,169 @@ +package schedule + +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 JobBase interface { + JobBase() BaseJobBaseImpl +} + +var _ JobBase = BaseJobBaseImpl{} + +type BaseJobBaseImpl struct { + ComponentId *string `json:"componentId,omitempty"` + ComputeId *string `json:"computeId,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExperimentName *string `json:"experimentName,omitempty"` + Identity IdentityConfiguration `json:"identity"` + IsArchived *bool `json:"isArchived,omitempty"` + JobType JobType `json:"jobType"` + NotificationSetting *NotificationSetting `json:"notificationSetting,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Services *map[string]JobService `json:"services,omitempty"` + Status *JobStatus `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +func (s BaseJobBaseImpl) JobBase() BaseJobBaseImpl { + return s +} + +var _ JobBase = RawJobBaseImpl{} + +// RawJobBaseImpl 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 RawJobBaseImpl struct { + jobBase BaseJobBaseImpl + Type string + Values map[string]interface{} +} + +func (s RawJobBaseImpl) JobBase() BaseJobBaseImpl { + return s.jobBase +} + +var _ json.Unmarshaler = &BaseJobBaseImpl{} + +func (s *BaseJobBaseImpl) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ComponentId *string `json:"componentId,omitempty"` + ComputeId *string `json:"computeId,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExperimentName *string `json:"experimentName,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + JobType JobType `json:"jobType"` + NotificationSetting *NotificationSetting `json:"notificationSetting,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Services *map[string]JobService `json:"services,omitempty"` + Status *JobStatus `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ComponentId = decoded.ComponentId + s.ComputeId = decoded.ComputeId + s.Description = decoded.Description + s.DisplayName = decoded.DisplayName + s.ExperimentName = decoded.ExperimentName + s.IsArchived = decoded.IsArchived + s.JobType = decoded.JobType + s.NotificationSetting = decoded.NotificationSetting + s.Properties = decoded.Properties + s.Services = decoded.Services + s.Status = decoded.Status + s.Tags = decoded.Tags + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling BaseJobBaseImpl into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["identity"]; ok { + impl, err := UnmarshalIdentityConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Identity' for 'BaseJobBaseImpl': %+v", err) + } + s.Identity = impl + } + + return nil +} + +func UnmarshalJobBaseImplementation(input []byte) (JobBase, 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 JobBase into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["jobType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AutoML") { + var out AutoMLJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AutoMLJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Command") { + var out CommandJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CommandJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Pipeline") { + var out PipelineJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into PipelineJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Spark") { + var out SparkJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SparkJob: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Sweep") { + var out SweepJob + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SweepJob: %+v", err) + } + return out, nil + } + + var parent BaseJobBaseImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseJobBaseImpl: %+v", err) + } + + return RawJobBaseImpl{ + jobBase: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_jobinput.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_jobinput.go new file mode 100644 index 00000000000..765c4feafe5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_jobinput.go @@ -0,0 +1,124 @@ +package schedule + +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 JobInput interface { + JobInput() BaseJobInputImpl +} + +var _ JobInput = BaseJobInputImpl{} + +type BaseJobInputImpl struct { + Description *string `json:"description,omitempty"` + JobInputType JobInputType `json:"jobInputType"` +} + +func (s BaseJobInputImpl) JobInput() BaseJobInputImpl { + return s +} + +var _ JobInput = RawJobInputImpl{} + +// RawJobInputImpl 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 RawJobInputImpl struct { + jobInput BaseJobInputImpl + Type string + Values map[string]interface{} +} + +func (s RawJobInputImpl) JobInput() BaseJobInputImpl { + return s.jobInput +} + +func UnmarshalJobInputImplementation(input []byte) (JobInput, 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 JobInput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["jobInputType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "custom_model") { + var out CustomModelJobInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CustomModelJobInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "literal") { + var out LiteralJobInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into LiteralJobInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "mlflow_model") { + var out MLFlowModelJobInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MLFlowModelJobInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "mltable") { + var out MLTableJobInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MLTableJobInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "triton_model") { + var out TritonModelJobInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into TritonModelJobInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "uri_file") { + var out UriFileJobInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into UriFileJobInput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "uri_folder") { + var out UriFolderJobInput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into UriFolderJobInput: %+v", err) + } + return out, nil + } + + var parent BaseJobInputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseJobInputImpl: %+v", err) + } + + return RawJobInputImpl{ + jobInput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_joblimits.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_joblimits.go new file mode 100644 index 00000000000..edddc82b3f8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_joblimits.go @@ -0,0 +1,84 @@ +package schedule + +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 JobLimits interface { + JobLimits() BaseJobLimitsImpl +} + +var _ JobLimits = BaseJobLimitsImpl{} + +type BaseJobLimitsImpl struct { + JobLimitsType JobLimitsType `json:"jobLimitsType"` + Timeout *string `json:"timeout,omitempty"` +} + +func (s BaseJobLimitsImpl) JobLimits() BaseJobLimitsImpl { + return s +} + +var _ JobLimits = RawJobLimitsImpl{} + +// RawJobLimitsImpl 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 RawJobLimitsImpl struct { + jobLimits BaseJobLimitsImpl + Type string + Values map[string]interface{} +} + +func (s RawJobLimitsImpl) JobLimits() BaseJobLimitsImpl { + return s.jobLimits +} + +func UnmarshalJobLimitsImplementation(input []byte) (JobLimits, 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 JobLimits into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["jobLimitsType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Command") { + var out CommandJobLimits + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CommandJobLimits: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Sweep") { + var out SweepJobLimits + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SweepJobLimits: %+v", err) + } + return out, nil + } + + var parent BaseJobLimitsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseJobLimitsImpl: %+v", err) + } + + return RawJobLimitsImpl{ + jobLimits: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_joboutput.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_joboutput.go new file mode 100644 index 00000000000..c4b8fccc556 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_joboutput.go @@ -0,0 +1,116 @@ +package schedule + +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 JobOutput interface { + JobOutput() BaseJobOutputImpl +} + +var _ JobOutput = BaseJobOutputImpl{} + +type BaseJobOutputImpl struct { + Description *string `json:"description,omitempty"` + JobOutputType JobOutputType `json:"jobOutputType"` +} + +func (s BaseJobOutputImpl) JobOutput() BaseJobOutputImpl { + return s +} + +var _ JobOutput = RawJobOutputImpl{} + +// RawJobOutputImpl 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 RawJobOutputImpl struct { + jobOutput BaseJobOutputImpl + Type string + Values map[string]interface{} +} + +func (s RawJobOutputImpl) JobOutput() BaseJobOutputImpl { + return s.jobOutput +} + +func UnmarshalJobOutputImplementation(input []byte) (JobOutput, 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 JobOutput into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["jobOutputType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "custom_model") { + var out CustomModelJobOutput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CustomModelJobOutput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "mlflow_model") { + var out MLFlowModelJobOutput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MLFlowModelJobOutput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "mltable") { + var out MLTableJobOutput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MLTableJobOutput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "triton_model") { + var out TritonModelJobOutput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into TritonModelJobOutput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "uri_file") { + var out UriFileJobOutput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into UriFileJobOutput: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "uri_folder") { + var out UriFolderJobOutput + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into UriFolderJobOutput: %+v", err) + } + return out, nil + } + + var parent BaseJobOutputImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseJobOutputImpl: %+v", err) + } + + return RawJobOutputImpl{ + jobOutput: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_jobresourceconfiguration.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_jobresourceconfiguration.go new file mode 100644 index 00000000000..632da9170e7 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_jobresourceconfiguration.go @@ -0,0 +1,12 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type JobResourceConfiguration struct { + DockerArgs *string `json:"dockerArgs,omitempty"` + InstanceCount *int64 `json:"instanceCount,omitempty"` + InstanceType *string `json:"instanceType,omitempty"` + Properties *map[string]interface{} `json:"properties,omitempty"` + ShmSize *string `json:"shmSize,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_jobscheduleaction.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_jobscheduleaction.go new file mode 100644 index 00000000000..6fe021ec2a7 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_jobscheduleaction.go @@ -0,0 +1,78 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ ScheduleActionBase = JobScheduleAction{} + +type JobScheduleAction struct { + JobDefinition JobBase `json:"jobDefinition"` + + // Fields inherited from ScheduleActionBase + + ActionType ScheduleActionType `json:"actionType"` +} + +func (s JobScheduleAction) ScheduleActionBase() BaseScheduleActionBaseImpl { + return BaseScheduleActionBaseImpl{ + ActionType: s.ActionType, + } +} + +var _ json.Marshaler = JobScheduleAction{} + +func (s JobScheduleAction) MarshalJSON() ([]byte, error) { + type wrapper JobScheduleAction + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling JobScheduleAction: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling JobScheduleAction: %+v", err) + } + + decoded["actionType"] = "CreateJob" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling JobScheduleAction: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &JobScheduleAction{} + +func (s *JobScheduleAction) UnmarshalJSON(bytes []byte) error { + var decoded struct { + ActionType ScheduleActionType `json:"actionType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.ActionType = decoded.ActionType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling JobScheduleAction into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["jobDefinition"]; ok { + impl, err := UnmarshalJobBaseImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'JobDefinition' for 'JobScheduleAction': %+v", err) + } + s.JobDefinition = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_jobservice.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_jobservice.go new file mode 100644 index 00000000000..2666f98437e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_jobservice.go @@ -0,0 +1,57 @@ +package schedule + +import ( + "encoding/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 JobService struct { + Endpoint *string `json:"endpoint,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + JobServiceType *string `json:"jobServiceType,omitempty"` + Nodes Nodes `json:"nodes"` + Port *int64 `json:"port,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Status *string `json:"status,omitempty"` +} + +var _ json.Unmarshaler = &JobService{} + +func (s *JobService) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Endpoint *string `json:"endpoint,omitempty"` + ErrorMessage *string `json:"errorMessage,omitempty"` + JobServiceType *string `json:"jobServiceType,omitempty"` + Port *int64 `json:"port,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Status *string `json:"status,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Endpoint = decoded.Endpoint + s.ErrorMessage = decoded.ErrorMessage + s.JobServiceType = decoded.JobServiceType + s.Port = decoded.Port + s.Properties = decoded.Properties + s.Status = decoded.Status + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling JobService into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["nodes"]; ok { + impl, err := UnmarshalNodesImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Nodes' for 'JobService': %+v", err) + } + s.Nodes = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_literaljobinput.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_literaljobinput.go new file mode 100644 index 00000000000..0879f3a20c7 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_literaljobinput.go @@ -0,0 +1,52 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobInput = LiteralJobInput{} + +type LiteralJobInput struct { + Value string `json:"value"` + + // Fields inherited from JobInput + + Description *string `json:"description,omitempty"` + JobInputType JobInputType `json:"jobInputType"` +} + +func (s LiteralJobInput) JobInput() BaseJobInputImpl { + return BaseJobInputImpl{ + Description: s.Description, + JobInputType: s.JobInputType, + } +} + +var _ json.Marshaler = LiteralJobInput{} + +func (s LiteralJobInput) MarshalJSON() ([]byte, error) { + type wrapper LiteralJobInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling LiteralJobInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling LiteralJobInput: %+v", err) + } + + decoded["jobInputType"] = "literal" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling LiteralJobInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_managedcomputeidentity.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_managedcomputeidentity.go new file mode 100644 index 00000000000..02728c026e1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_managedcomputeidentity.go @@ -0,0 +1,52 @@ +package schedule + +import ( + "encoding/json" + "fmt" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ MonitorComputeIdentityBase = ManagedComputeIdentity{} + +type ManagedComputeIdentity struct { + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + + // Fields inherited from MonitorComputeIdentityBase + + ComputeIdentityType MonitorComputeIdentityType `json:"computeIdentityType"` +} + +func (s ManagedComputeIdentity) MonitorComputeIdentityBase() BaseMonitorComputeIdentityBaseImpl { + return BaseMonitorComputeIdentityBaseImpl{ + ComputeIdentityType: s.ComputeIdentityType, + } +} + +var _ json.Marshaler = ManagedComputeIdentity{} + +func (s ManagedComputeIdentity) MarshalJSON() ([]byte, error) { + type wrapper ManagedComputeIdentity + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ManagedComputeIdentity: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ManagedComputeIdentity: %+v", err) + } + + decoded["computeIdentityType"] = "ManagedIdentity" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ManagedComputeIdentity: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_managedidentity.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_managedidentity.go new file mode 100644 index 00000000000..208e7b9078d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_managedidentity.go @@ -0,0 +1,52 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ IdentityConfiguration = ManagedIdentity{} + +type ManagedIdentity struct { + ClientId *string `json:"clientId,omitempty"` + ObjectId *string `json:"objectId,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` + + // Fields inherited from IdentityConfiguration + + IdentityType IdentityConfigurationType `json:"identityType"` +} + +func (s ManagedIdentity) IdentityConfiguration() BaseIdentityConfigurationImpl { + return BaseIdentityConfigurationImpl{ + IdentityType: s.IdentityType, + } +} + +var _ json.Marshaler = ManagedIdentity{} + +func (s ManagedIdentity) MarshalJSON() ([]byte, error) { + type wrapper ManagedIdentity + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ManagedIdentity: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ManagedIdentity: %+v", err) + } + + decoded["identityType"] = "Managed" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ManagedIdentity: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_medianstoppingpolicy.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_medianstoppingpolicy.go new file mode 100644 index 00000000000..6e54080a23c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_medianstoppingpolicy.go @@ -0,0 +1,53 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EarlyTerminationPolicy = MedianStoppingPolicy{} + +type MedianStoppingPolicy struct { + + // Fields inherited from EarlyTerminationPolicy + + DelayEvaluation *int64 `json:"delayEvaluation,omitempty"` + EvaluationInterval *int64 `json:"evaluationInterval,omitempty"` + PolicyType EarlyTerminationPolicyType `json:"policyType"` +} + +func (s MedianStoppingPolicy) EarlyTerminationPolicy() BaseEarlyTerminationPolicyImpl { + return BaseEarlyTerminationPolicyImpl{ + DelayEvaluation: s.DelayEvaluation, + EvaluationInterval: s.EvaluationInterval, + PolicyType: s.PolicyType, + } +} + +var _ json.Marshaler = MedianStoppingPolicy{} + +func (s MedianStoppingPolicy) MarshalJSON() ([]byte, error) { + type wrapper MedianStoppingPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MedianStoppingPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MedianStoppingPolicy: %+v", err) + } + + decoded["policyType"] = "MedianStopping" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MedianStoppingPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_mlflowmodeljobinput.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_mlflowmodeljobinput.go new file mode 100644 index 00000000000..4ff9169eb7c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_mlflowmodeljobinput.go @@ -0,0 +1,53 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobInput = MLFlowModelJobInput{} + +type MLFlowModelJobInput struct { + Mode *InputDeliveryMode `json:"mode,omitempty"` + Uri string `json:"uri"` + + // Fields inherited from JobInput + + Description *string `json:"description,omitempty"` + JobInputType JobInputType `json:"jobInputType"` +} + +func (s MLFlowModelJobInput) JobInput() BaseJobInputImpl { + return BaseJobInputImpl{ + Description: s.Description, + JobInputType: s.JobInputType, + } +} + +var _ json.Marshaler = MLFlowModelJobInput{} + +func (s MLFlowModelJobInput) MarshalJSON() ([]byte, error) { + type wrapper MLFlowModelJobInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MLFlowModelJobInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MLFlowModelJobInput: %+v", err) + } + + decoded["jobInputType"] = "mlflow_model" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MLFlowModelJobInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_mlflowmodeljoboutput.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_mlflowmodeljoboutput.go new file mode 100644 index 00000000000..584666b570b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_mlflowmodeljoboutput.go @@ -0,0 +1,53 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobOutput = MLFlowModelJobOutput{} + +type MLFlowModelJobOutput struct { + Mode *OutputDeliveryMode `json:"mode,omitempty"` + Uri *string `json:"uri,omitempty"` + + // Fields inherited from JobOutput + + Description *string `json:"description,omitempty"` + JobOutputType JobOutputType `json:"jobOutputType"` +} + +func (s MLFlowModelJobOutput) JobOutput() BaseJobOutputImpl { + return BaseJobOutputImpl{ + Description: s.Description, + JobOutputType: s.JobOutputType, + } +} + +var _ json.Marshaler = MLFlowModelJobOutput{} + +func (s MLFlowModelJobOutput) MarshalJSON() ([]byte, error) { + type wrapper MLFlowModelJobOutput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MLFlowModelJobOutput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MLFlowModelJobOutput: %+v", err) + } + + decoded["jobOutputType"] = "mlflow_model" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MLFlowModelJobOutput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_mltablejobinput.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_mltablejobinput.go new file mode 100644 index 00000000000..364d527d8b1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_mltablejobinput.go @@ -0,0 +1,53 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobInput = MLTableJobInput{} + +type MLTableJobInput struct { + Mode *InputDeliveryMode `json:"mode,omitempty"` + Uri string `json:"uri"` + + // Fields inherited from JobInput + + Description *string `json:"description,omitempty"` + JobInputType JobInputType `json:"jobInputType"` +} + +func (s MLTableJobInput) JobInput() BaseJobInputImpl { + return BaseJobInputImpl{ + Description: s.Description, + JobInputType: s.JobInputType, + } +} + +var _ json.Marshaler = MLTableJobInput{} + +func (s MLTableJobInput) MarshalJSON() ([]byte, error) { + type wrapper MLTableJobInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MLTableJobInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MLTableJobInput: %+v", err) + } + + decoded["jobInputType"] = "mltable" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MLTableJobInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_mltablejoboutput.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_mltablejoboutput.go new file mode 100644 index 00000000000..6bc782d1f61 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_mltablejoboutput.go @@ -0,0 +1,53 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobOutput = MLTableJobOutput{} + +type MLTableJobOutput struct { + Mode *OutputDeliveryMode `json:"mode,omitempty"` + Uri *string `json:"uri,omitempty"` + + // Fields inherited from JobOutput + + Description *string `json:"description,omitempty"` + JobOutputType JobOutputType `json:"jobOutputType"` +} + +func (s MLTableJobOutput) JobOutput() BaseJobOutputImpl { + return BaseJobOutputImpl{ + Description: s.Description, + JobOutputType: s.JobOutputType, + } +} + +var _ json.Marshaler = MLTableJobOutput{} + +func (s MLTableJobOutput) MarshalJSON() ([]byte, error) { + type wrapper MLTableJobOutput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MLTableJobOutput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MLTableJobOutput: %+v", err) + } + + decoded["jobOutputType"] = "mltable" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MLTableJobOutput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitorcomputeconfigurationbase.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitorcomputeconfigurationbase.go new file mode 100644 index 00000000000..ce959b13def --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitorcomputeconfigurationbase.go @@ -0,0 +1,75 @@ +package schedule + +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 MonitorComputeConfigurationBase interface { + MonitorComputeConfigurationBase() BaseMonitorComputeConfigurationBaseImpl +} + +var _ MonitorComputeConfigurationBase = BaseMonitorComputeConfigurationBaseImpl{} + +type BaseMonitorComputeConfigurationBaseImpl struct { + ComputeType MonitorComputeType `json:"computeType"` +} + +func (s BaseMonitorComputeConfigurationBaseImpl) MonitorComputeConfigurationBase() BaseMonitorComputeConfigurationBaseImpl { + return s +} + +var _ MonitorComputeConfigurationBase = RawMonitorComputeConfigurationBaseImpl{} + +// RawMonitorComputeConfigurationBaseImpl 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 RawMonitorComputeConfigurationBaseImpl struct { + monitorComputeConfigurationBase BaseMonitorComputeConfigurationBaseImpl + Type string + Values map[string]interface{} +} + +func (s RawMonitorComputeConfigurationBaseImpl) MonitorComputeConfigurationBase() BaseMonitorComputeConfigurationBaseImpl { + return s.monitorComputeConfigurationBase +} + +func UnmarshalMonitorComputeConfigurationBaseImplementation(input []byte) (MonitorComputeConfigurationBase, 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 MonitorComputeConfigurationBase into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["computeType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "ServerlessSpark") { + var out MonitorServerlessSparkCompute + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into MonitorServerlessSparkCompute: %+v", err) + } + return out, nil + } + + var parent BaseMonitorComputeConfigurationBaseImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseMonitorComputeConfigurationBaseImpl: %+v", err) + } + + return RawMonitorComputeConfigurationBaseImpl{ + monitorComputeConfigurationBase: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitorcomputeidentitybase.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitorcomputeidentitybase.go new file mode 100644 index 00000000000..9aa6eec74bd --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitorcomputeidentitybase.go @@ -0,0 +1,83 @@ +package schedule + +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 MonitorComputeIdentityBase interface { + MonitorComputeIdentityBase() BaseMonitorComputeIdentityBaseImpl +} + +var _ MonitorComputeIdentityBase = BaseMonitorComputeIdentityBaseImpl{} + +type BaseMonitorComputeIdentityBaseImpl struct { + ComputeIdentityType MonitorComputeIdentityType `json:"computeIdentityType"` +} + +func (s BaseMonitorComputeIdentityBaseImpl) MonitorComputeIdentityBase() BaseMonitorComputeIdentityBaseImpl { + return s +} + +var _ MonitorComputeIdentityBase = RawMonitorComputeIdentityBaseImpl{} + +// RawMonitorComputeIdentityBaseImpl 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 RawMonitorComputeIdentityBaseImpl struct { + monitorComputeIdentityBase BaseMonitorComputeIdentityBaseImpl + Type string + Values map[string]interface{} +} + +func (s RawMonitorComputeIdentityBaseImpl) MonitorComputeIdentityBase() BaseMonitorComputeIdentityBaseImpl { + return s.monitorComputeIdentityBase +} + +func UnmarshalMonitorComputeIdentityBaseImplementation(input []byte) (MonitorComputeIdentityBase, 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 MonitorComputeIdentityBase into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["computeIdentityType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AmlToken") { + var out AmlTokenComputeIdentity + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AmlTokenComputeIdentity: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ManagedIdentity") { + var out ManagedComputeIdentity + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ManagedComputeIdentity: %+v", err) + } + return out, nil + } + + var parent BaseMonitorComputeIdentityBaseImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseMonitorComputeIdentityBaseImpl: %+v", err) + } + + return RawMonitorComputeIdentityBaseImpl{ + monitorComputeIdentityBase: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitordefinition.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitordefinition.go new file mode 100644 index 00000000000..7b3e5152bba --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitordefinition.go @@ -0,0 +1,63 @@ +package schedule + +import ( + "encoding/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 MonitorDefinition struct { + AlertNotificationSettings *MonitorNotificationSettings `json:"alertNotificationSettings,omitempty"` + ComputeConfiguration MonitorComputeConfigurationBase `json:"computeConfiguration"` + MonitoringTarget *MonitoringTarget `json:"monitoringTarget,omitempty"` + Signals map[string]MonitoringSignalBase `json:"signals"` +} + +var _ json.Unmarshaler = &MonitorDefinition{} + +func (s *MonitorDefinition) UnmarshalJSON(bytes []byte) error { + var decoded struct { + AlertNotificationSettings *MonitorNotificationSettings `json:"alertNotificationSettings,omitempty"` + MonitoringTarget *MonitoringTarget `json:"monitoringTarget,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.AlertNotificationSettings = decoded.AlertNotificationSettings + s.MonitoringTarget = decoded.MonitoringTarget + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling MonitorDefinition into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["computeConfiguration"]; ok { + impl, err := UnmarshalMonitorComputeConfigurationBaseImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ComputeConfiguration' for 'MonitorDefinition': %+v", err) + } + s.ComputeConfiguration = impl + } + + if v, ok := temp["signals"]; ok { + var dictionaryTemp map[string]json.RawMessage + if err := json.Unmarshal(v, &dictionaryTemp); err != nil { + return fmt.Errorf("unmarshaling Signals into dictionary map[string]json.RawMessage: %+v", err) + } + + output := make(map[string]MonitoringSignalBase) + for key, val := range dictionaryTemp { + impl, err := UnmarshalMonitoringSignalBaseImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling key %q field 'Signals' for 'MonitorDefinition': %+v", key, err) + } + output[key] = impl + } + s.Signals = output + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitoremailnotificationsettings.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitoremailnotificationsettings.go new file mode 100644 index 00000000000..778c51900d1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitoremailnotificationsettings.go @@ -0,0 +1,8 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MonitorEmailNotificationSettings struct { + Emails *[]string `json:"emails,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitoringfeaturefilterbase.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitoringfeaturefilterbase.go new file mode 100644 index 00000000000..006ac2af074 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitoringfeaturefilterbase.go @@ -0,0 +1,91 @@ +package schedule + +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 MonitoringFeatureFilterBase interface { + MonitoringFeatureFilterBase() BaseMonitoringFeatureFilterBaseImpl +} + +var _ MonitoringFeatureFilterBase = BaseMonitoringFeatureFilterBaseImpl{} + +type BaseMonitoringFeatureFilterBaseImpl struct { + FilterType MonitoringFeatureFilterType `json:"filterType"` +} + +func (s BaseMonitoringFeatureFilterBaseImpl) MonitoringFeatureFilterBase() BaseMonitoringFeatureFilterBaseImpl { + return s +} + +var _ MonitoringFeatureFilterBase = RawMonitoringFeatureFilterBaseImpl{} + +// RawMonitoringFeatureFilterBaseImpl 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 RawMonitoringFeatureFilterBaseImpl struct { + monitoringFeatureFilterBase BaseMonitoringFeatureFilterBaseImpl + Type string + Values map[string]interface{} +} + +func (s RawMonitoringFeatureFilterBaseImpl) MonitoringFeatureFilterBase() BaseMonitoringFeatureFilterBaseImpl { + return s.monitoringFeatureFilterBase +} + +func UnmarshalMonitoringFeatureFilterBaseImplementation(input []byte) (MonitoringFeatureFilterBase, 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 MonitoringFeatureFilterBase into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["filterType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AllFeatures") { + var out AllFeatures + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AllFeatures: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "FeatureSubset") { + var out FeatureSubset + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into FeatureSubset: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "TopNByAttribution") { + var out TopNFeaturesByAttribution + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into TopNFeaturesByAttribution: %+v", err) + } + return out, nil + } + + var parent BaseMonitoringFeatureFilterBaseImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseMonitoringFeatureFilterBaseImpl: %+v", err) + } + + return RawMonitoringFeatureFilterBaseImpl{ + monitoringFeatureFilterBase: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitoringinputdatabase.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitoringinputdatabase.go new file mode 100644 index 00000000000..9cc419d0577 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitoringinputdatabase.go @@ -0,0 +1,95 @@ +package schedule + +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 MonitoringInputDataBase interface { + MonitoringInputDataBase() BaseMonitoringInputDataBaseImpl +} + +var _ MonitoringInputDataBase = BaseMonitoringInputDataBaseImpl{} + +type BaseMonitoringInputDataBaseImpl struct { + Columns *map[string]string `json:"columns,omitempty"` + DataContext *string `json:"dataContext,omitempty"` + InputDataType MonitoringInputDataType `json:"inputDataType"` + JobInputType JobInputType `json:"jobInputType"` + Uri string `json:"uri"` +} + +func (s BaseMonitoringInputDataBaseImpl) MonitoringInputDataBase() BaseMonitoringInputDataBaseImpl { + return s +} + +var _ MonitoringInputDataBase = RawMonitoringInputDataBaseImpl{} + +// RawMonitoringInputDataBaseImpl 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 RawMonitoringInputDataBaseImpl struct { + monitoringInputDataBase BaseMonitoringInputDataBaseImpl + Type string + Values map[string]interface{} +} + +func (s RawMonitoringInputDataBaseImpl) MonitoringInputDataBase() BaseMonitoringInputDataBaseImpl { + return s.monitoringInputDataBase +} + +func UnmarshalMonitoringInputDataBaseImplementation(input []byte) (MonitoringInputDataBase, 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 MonitoringInputDataBase into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["inputDataType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Fixed") { + var out FixedInputData + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into FixedInputData: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Rolling") { + var out RollingInputData + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RollingInputData: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Static") { + var out StaticInputData + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into StaticInputData: %+v", err) + } + return out, nil + } + + var parent BaseMonitoringInputDataBaseImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseMonitoringInputDataBaseImpl: %+v", err) + } + + return RawMonitoringInputDataBaseImpl{ + monitoringInputDataBase: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitoringsignalbase.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitoringsignalbase.go new file mode 100644 index 00000000000..01f8d09c1c7 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitoringsignalbase.go @@ -0,0 +1,109 @@ +package schedule + +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 MonitoringSignalBase interface { + MonitoringSignalBase() BaseMonitoringSignalBaseImpl +} + +var _ MonitoringSignalBase = BaseMonitoringSignalBaseImpl{} + +type BaseMonitoringSignalBaseImpl struct { + NotificationTypes *[]MonitoringNotificationType `json:"notificationTypes,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + SignalType MonitoringSignalType `json:"signalType"` +} + +func (s BaseMonitoringSignalBaseImpl) MonitoringSignalBase() BaseMonitoringSignalBaseImpl { + return s +} + +var _ MonitoringSignalBase = RawMonitoringSignalBaseImpl{} + +// RawMonitoringSignalBaseImpl 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 RawMonitoringSignalBaseImpl struct { + monitoringSignalBase BaseMonitoringSignalBaseImpl + Type string + Values map[string]interface{} +} + +func (s RawMonitoringSignalBaseImpl) MonitoringSignalBase() BaseMonitoringSignalBaseImpl { + return s.monitoringSignalBase +} + +func UnmarshalMonitoringSignalBaseImplementation(input []byte) (MonitoringSignalBase, 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 MonitoringSignalBase into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["signalType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Custom") { + var out CustomMonitoringSignal + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CustomMonitoringSignal: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DataDrift") { + var out DataDriftMonitoringSignal + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DataDriftMonitoringSignal: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "DataQuality") { + var out DataQualityMonitoringSignal + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into DataQualityMonitoringSignal: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "FeatureAttributionDrift") { + var out FeatureAttributionDriftMonitoringSignal + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into FeatureAttributionDriftMonitoringSignal: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "PredictionDrift") { + var out PredictionDriftMonitoringSignal + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into PredictionDriftMonitoringSignal: %+v", err) + } + return out, nil + } + + var parent BaseMonitoringSignalBaseImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseMonitoringSignalBaseImpl: %+v", err) + } + + return RawMonitoringSignalBaseImpl{ + monitoringSignalBase: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitoringtarget.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitoringtarget.go new file mode 100644 index 00000000000..3f0fc5fd463 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitoringtarget.go @@ -0,0 +1,10 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MonitoringTarget struct { + DeploymentId *string `json:"deploymentId,omitempty"` + ModelId *string `json:"modelId,omitempty"` + TaskType ModelTaskType `json:"taskType"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitoringthreshold.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitoringthreshold.go new file mode 100644 index 00000000000..4877dee6b02 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitoringthreshold.go @@ -0,0 +1,8 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MonitoringThreshold struct { + Value *float64 `json:"value,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitornotificationsettings.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitornotificationsettings.go new file mode 100644 index 00000000000..2e0a9a5e7f6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitornotificationsettings.go @@ -0,0 +1,8 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type MonitorNotificationSettings struct { + EmailNotificationSettings *MonitorEmailNotificationSettings `json:"emailNotificationSettings,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitorserverlesssparkcompute.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitorserverlesssparkcompute.go new file mode 100644 index 00000000000..03b897b79da --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_monitorserverlesssparkcompute.go @@ -0,0 +1,84 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ MonitorComputeConfigurationBase = MonitorServerlessSparkCompute{} + +type MonitorServerlessSparkCompute struct { + ComputeIdentity MonitorComputeIdentityBase `json:"computeIdentity"` + InstanceType string `json:"instanceType"` + RuntimeVersion string `json:"runtimeVersion"` + + // Fields inherited from MonitorComputeConfigurationBase + + ComputeType MonitorComputeType `json:"computeType"` +} + +func (s MonitorServerlessSparkCompute) MonitorComputeConfigurationBase() BaseMonitorComputeConfigurationBaseImpl { + return BaseMonitorComputeConfigurationBaseImpl{ + ComputeType: s.ComputeType, + } +} + +var _ json.Marshaler = MonitorServerlessSparkCompute{} + +func (s MonitorServerlessSparkCompute) MarshalJSON() ([]byte, error) { + type wrapper MonitorServerlessSparkCompute + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling MonitorServerlessSparkCompute: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling MonitorServerlessSparkCompute: %+v", err) + } + + decoded["computeType"] = "ServerlessSpark" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling MonitorServerlessSparkCompute: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &MonitorServerlessSparkCompute{} + +func (s *MonitorServerlessSparkCompute) UnmarshalJSON(bytes []byte) error { + var decoded struct { + InstanceType string `json:"instanceType"` + RuntimeVersion string `json:"runtimeVersion"` + ComputeType MonitorComputeType `json:"computeType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.InstanceType = decoded.InstanceType + s.RuntimeVersion = decoded.RuntimeVersion + s.ComputeType = decoded.ComputeType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling MonitorServerlessSparkCompute into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["computeIdentity"]; ok { + impl, err := UnmarshalMonitorComputeIdentityBaseImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ComputeIdentity' for 'MonitorServerlessSparkCompute': %+v", err) + } + s.ComputeIdentity = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_mpi.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_mpi.go new file mode 100644 index 00000000000..3b85b2b619f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_mpi.go @@ -0,0 +1,50 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DistributionConfiguration = Mpi{} + +type Mpi struct { + ProcessCountPerInstance *int64 `json:"processCountPerInstance,omitempty"` + + // Fields inherited from DistributionConfiguration + + DistributionType DistributionType `json:"distributionType"` +} + +func (s Mpi) DistributionConfiguration() BaseDistributionConfigurationImpl { + return BaseDistributionConfigurationImpl{ + DistributionType: s.DistributionType, + } +} + +var _ json.Marshaler = Mpi{} + +func (s Mpi) MarshalJSON() ([]byte, error) { + type wrapper Mpi + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling Mpi: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling Mpi: %+v", err) + } + + decoded["distributionType"] = "Mpi" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling Mpi: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_ncrossvalidations.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_ncrossvalidations.go new file mode 100644 index 00000000000..f510b824ca8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_ncrossvalidations.go @@ -0,0 +1,83 @@ +package schedule + +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 NCrossValidations interface { + NCrossValidations() BaseNCrossValidationsImpl +} + +var _ NCrossValidations = BaseNCrossValidationsImpl{} + +type BaseNCrossValidationsImpl struct { + Mode NCrossValidationsMode `json:"mode"` +} + +func (s BaseNCrossValidationsImpl) NCrossValidations() BaseNCrossValidationsImpl { + return s +} + +var _ NCrossValidations = RawNCrossValidationsImpl{} + +// RawNCrossValidationsImpl 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 RawNCrossValidationsImpl struct { + nCrossValidations BaseNCrossValidationsImpl + Type string + Values map[string]interface{} +} + +func (s RawNCrossValidationsImpl) NCrossValidations() BaseNCrossValidationsImpl { + return s.nCrossValidations +} + +func UnmarshalNCrossValidationsImplementation(input []byte) (NCrossValidations, 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 NCrossValidations into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["mode"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Auto") { + var out AutoNCrossValidations + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AutoNCrossValidations: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Custom") { + var out CustomNCrossValidations + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CustomNCrossValidations: %+v", err) + } + return out, nil + } + + var parent BaseNCrossValidationsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseNCrossValidationsImpl: %+v", err) + } + + return RawNCrossValidationsImpl{ + nCrossValidations: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_nlpverticallimitsettings.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_nlpverticallimitsettings.go new file mode 100644 index 00000000000..9bad9f89026 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_nlpverticallimitsettings.go @@ -0,0 +1,10 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NlpVerticalLimitSettings struct { + MaxConcurrentTrials *int64 `json:"maxConcurrentTrials,omitempty"` + MaxTrials *int64 `json:"maxTrials,omitempty"` + Timeout *string `json:"timeout,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_nodes.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_nodes.go new file mode 100644 index 00000000000..eafe66a06a5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_nodes.go @@ -0,0 +1,75 @@ +package schedule + +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 Nodes interface { + Nodes() BaseNodesImpl +} + +var _ Nodes = BaseNodesImpl{} + +type BaseNodesImpl struct { + NodesValueType NodesValueType `json:"nodesValueType"` +} + +func (s BaseNodesImpl) Nodes() BaseNodesImpl { + return s +} + +var _ Nodes = RawNodesImpl{} + +// RawNodesImpl 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 RawNodesImpl struct { + nodes BaseNodesImpl + Type string + Values map[string]interface{} +} + +func (s RawNodesImpl) Nodes() BaseNodesImpl { + return s.nodes +} + +func UnmarshalNodesImplementation(input []byte) (Nodes, 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 Nodes into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["nodesValueType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "All") { + var out AllNodes + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AllNodes: %+v", err) + } + return out, nil + } + + var parent BaseNodesImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseNodesImpl: %+v", err) + } + + return RawNodesImpl{ + nodes: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_notificationsetting.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_notificationsetting.go new file mode 100644 index 00000000000..006555db3b9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_notificationsetting.go @@ -0,0 +1,54 @@ +package schedule + +import ( + "encoding/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 NotificationSetting struct { + EmailOn *[]EmailNotificationEnableType `json:"emailOn,omitempty"` + Emails *[]string `json:"emails,omitempty"` + WebHooks *map[string]Webhook `json:"webhooks,omitempty"` +} + +var _ json.Unmarshaler = &NotificationSetting{} + +func (s *NotificationSetting) UnmarshalJSON(bytes []byte) error { + var decoded struct { + EmailOn *[]EmailNotificationEnableType `json:"emailOn,omitempty"` + Emails *[]string `json:"emails,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.EmailOn = decoded.EmailOn + s.Emails = decoded.Emails + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling NotificationSetting into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["webhooks"]; ok { + var dictionaryTemp map[string]json.RawMessage + if err := json.Unmarshal(v, &dictionaryTemp); err != nil { + return fmt.Errorf("unmarshaling WebHooks into dictionary map[string]json.RawMessage: %+v", err) + } + + output := make(map[string]Webhook) + for key, val := range dictionaryTemp { + impl, err := UnmarshalWebhookImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling key %q field 'WebHooks' for 'NotificationSetting': %+v", key, err) + } + output[key] = impl + } + s.WebHooks = &output + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_numericaldatadriftmetricthreshold.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_numericaldatadriftmetricthreshold.go new file mode 100644 index 00000000000..3460ccff0a9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_numericaldatadriftmetricthreshold.go @@ -0,0 +1,52 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DataDriftMetricThresholdBase = NumericalDataDriftMetricThreshold{} + +type NumericalDataDriftMetricThreshold struct { + Metric NumericalDataDriftMetric `json:"metric"` + + // Fields inherited from DataDriftMetricThresholdBase + + DataType MonitoringFeatureDataType `json:"dataType"` + Threshold *MonitoringThreshold `json:"threshold,omitempty"` +} + +func (s NumericalDataDriftMetricThreshold) DataDriftMetricThresholdBase() BaseDataDriftMetricThresholdBaseImpl { + return BaseDataDriftMetricThresholdBaseImpl{ + DataType: s.DataType, + Threshold: s.Threshold, + } +} + +var _ json.Marshaler = NumericalDataDriftMetricThreshold{} + +func (s NumericalDataDriftMetricThreshold) MarshalJSON() ([]byte, error) { + type wrapper NumericalDataDriftMetricThreshold + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling NumericalDataDriftMetricThreshold: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling NumericalDataDriftMetricThreshold: %+v", err) + } + + decoded["dataType"] = "Numerical" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling NumericalDataDriftMetricThreshold: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_numericaldataqualitymetricthreshold.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_numericaldataqualitymetricthreshold.go new file mode 100644 index 00000000000..f1eda825312 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_numericaldataqualitymetricthreshold.go @@ -0,0 +1,52 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DataQualityMetricThresholdBase = NumericalDataQualityMetricThreshold{} + +type NumericalDataQualityMetricThreshold struct { + Metric NumericalDataQualityMetric `json:"metric"` + + // Fields inherited from DataQualityMetricThresholdBase + + DataType MonitoringFeatureDataType `json:"dataType"` + Threshold *MonitoringThreshold `json:"threshold,omitempty"` +} + +func (s NumericalDataQualityMetricThreshold) DataQualityMetricThresholdBase() BaseDataQualityMetricThresholdBaseImpl { + return BaseDataQualityMetricThresholdBaseImpl{ + DataType: s.DataType, + Threshold: s.Threshold, + } +} + +var _ json.Marshaler = NumericalDataQualityMetricThreshold{} + +func (s NumericalDataQualityMetricThreshold) MarshalJSON() ([]byte, error) { + type wrapper NumericalDataQualityMetricThreshold + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling NumericalDataQualityMetricThreshold: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling NumericalDataQualityMetricThreshold: %+v", err) + } + + decoded["dataType"] = "Numerical" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling NumericalDataQualityMetricThreshold: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_numericalpredictiondriftmetricthreshold.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_numericalpredictiondriftmetricthreshold.go new file mode 100644 index 00000000000..10824f04be8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_numericalpredictiondriftmetricthreshold.go @@ -0,0 +1,52 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ PredictionDriftMetricThresholdBase = NumericalPredictionDriftMetricThreshold{} + +type NumericalPredictionDriftMetricThreshold struct { + Metric NumericalPredictionDriftMetric `json:"metric"` + + // Fields inherited from PredictionDriftMetricThresholdBase + + DataType MonitoringFeatureDataType `json:"dataType"` + Threshold *MonitoringThreshold `json:"threshold,omitempty"` +} + +func (s NumericalPredictionDriftMetricThreshold) PredictionDriftMetricThresholdBase() BasePredictionDriftMetricThresholdBaseImpl { + return BasePredictionDriftMetricThresholdBaseImpl{ + DataType: s.DataType, + Threshold: s.Threshold, + } +} + +var _ json.Marshaler = NumericalPredictionDriftMetricThreshold{} + +func (s NumericalPredictionDriftMetricThreshold) MarshalJSON() ([]byte, error) { + type wrapper NumericalPredictionDriftMetricThreshold + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling NumericalPredictionDriftMetricThreshold: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling NumericalPredictionDriftMetricThreshold: %+v", err) + } + + decoded["dataType"] = "Numerical" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling NumericalPredictionDriftMetricThreshold: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_objective.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_objective.go new file mode 100644 index 00000000000..682dcb1bc58 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_objective.go @@ -0,0 +1,9 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Objective struct { + Goal Goal `json:"goal"` + PrimaryMetric string `json:"primaryMetric"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_pipelinejob.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_pipelinejob.go new file mode 100644 index 00000000000..27f58db3e6b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_pipelinejob.go @@ -0,0 +1,168 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobBase = PipelineJob{} + +type PipelineJob struct { + Inputs *map[string]JobInput `json:"inputs,omitempty"` + Jobs *map[string]interface{} `json:"jobs,omitempty"` + Outputs *map[string]JobOutput `json:"outputs,omitempty"` + Settings *interface{} `json:"settings,omitempty"` + SourceJobId *string `json:"sourceJobId,omitempty"` + + // Fields inherited from JobBase + + ComponentId *string `json:"componentId,omitempty"` + ComputeId *string `json:"computeId,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExperimentName *string `json:"experimentName,omitempty"` + Identity IdentityConfiguration `json:"identity"` + IsArchived *bool `json:"isArchived,omitempty"` + JobType JobType `json:"jobType"` + NotificationSetting *NotificationSetting `json:"notificationSetting,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Services *map[string]JobService `json:"services,omitempty"` + Status *JobStatus `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +func (s PipelineJob) JobBase() BaseJobBaseImpl { + return BaseJobBaseImpl{ + ComponentId: s.ComponentId, + ComputeId: s.ComputeId, + Description: s.Description, + DisplayName: s.DisplayName, + ExperimentName: s.ExperimentName, + Identity: s.Identity, + IsArchived: s.IsArchived, + JobType: s.JobType, + NotificationSetting: s.NotificationSetting, + Properties: s.Properties, + Services: s.Services, + Status: s.Status, + Tags: s.Tags, + } +} + +var _ json.Marshaler = PipelineJob{} + +func (s PipelineJob) MarshalJSON() ([]byte, error) { + type wrapper PipelineJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling PipelineJob: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling PipelineJob: %+v", err) + } + + decoded["jobType"] = "Pipeline" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling PipelineJob: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &PipelineJob{} + +func (s *PipelineJob) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Jobs *map[string]interface{} `json:"jobs,omitempty"` + Settings *interface{} `json:"settings,omitempty"` + SourceJobId *string `json:"sourceJobId,omitempty"` + ComponentId *string `json:"componentId,omitempty"` + ComputeId *string `json:"computeId,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExperimentName *string `json:"experimentName,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + JobType JobType `json:"jobType"` + NotificationSetting *NotificationSetting `json:"notificationSetting,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Services *map[string]JobService `json:"services,omitempty"` + Status *JobStatus `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Jobs = decoded.Jobs + s.Settings = decoded.Settings + s.SourceJobId = decoded.SourceJobId + s.ComponentId = decoded.ComponentId + s.ComputeId = decoded.ComputeId + s.Description = decoded.Description + s.DisplayName = decoded.DisplayName + s.ExperimentName = decoded.ExperimentName + s.IsArchived = decoded.IsArchived + s.JobType = decoded.JobType + s.NotificationSetting = decoded.NotificationSetting + s.Properties = decoded.Properties + s.Services = decoded.Services + s.Status = decoded.Status + s.Tags = decoded.Tags + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling PipelineJob into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["identity"]; ok { + impl, err := UnmarshalIdentityConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Identity' for 'PipelineJob': %+v", err) + } + s.Identity = impl + } + + if v, ok := temp["inputs"]; ok { + var dictionaryTemp map[string]json.RawMessage + if err := json.Unmarshal(v, &dictionaryTemp); err != nil { + return fmt.Errorf("unmarshaling Inputs into dictionary map[string]json.RawMessage: %+v", err) + } + + output := make(map[string]JobInput) + for key, val := range dictionaryTemp { + impl, err := UnmarshalJobInputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling key %q field 'Inputs' for 'PipelineJob': %+v", key, err) + } + output[key] = impl + } + s.Inputs = &output + } + + if v, ok := temp["outputs"]; ok { + var dictionaryTemp map[string]json.RawMessage + if err := json.Unmarshal(v, &dictionaryTemp); err != nil { + return fmt.Errorf("unmarshaling Outputs into dictionary map[string]json.RawMessage: %+v", err) + } + + output := make(map[string]JobOutput) + for key, val := range dictionaryTemp { + impl, err := UnmarshalJobOutputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling key %q field 'Outputs' for 'PipelineJob': %+v", key, err) + } + output[key] = impl + } + s.Outputs = &output + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_predictiondriftmetricthresholdbase.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_predictiondriftmetricthresholdbase.go new file mode 100644 index 00000000000..55dce19bdfb --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_predictiondriftmetricthresholdbase.go @@ -0,0 +1,84 @@ +package schedule + +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 PredictionDriftMetricThresholdBase interface { + PredictionDriftMetricThresholdBase() BasePredictionDriftMetricThresholdBaseImpl +} + +var _ PredictionDriftMetricThresholdBase = BasePredictionDriftMetricThresholdBaseImpl{} + +type BasePredictionDriftMetricThresholdBaseImpl struct { + DataType MonitoringFeatureDataType `json:"dataType"` + Threshold *MonitoringThreshold `json:"threshold,omitempty"` +} + +func (s BasePredictionDriftMetricThresholdBaseImpl) PredictionDriftMetricThresholdBase() BasePredictionDriftMetricThresholdBaseImpl { + return s +} + +var _ PredictionDriftMetricThresholdBase = RawPredictionDriftMetricThresholdBaseImpl{} + +// RawPredictionDriftMetricThresholdBaseImpl 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 RawPredictionDriftMetricThresholdBaseImpl struct { + predictionDriftMetricThresholdBase BasePredictionDriftMetricThresholdBaseImpl + Type string + Values map[string]interface{} +} + +func (s RawPredictionDriftMetricThresholdBaseImpl) PredictionDriftMetricThresholdBase() BasePredictionDriftMetricThresholdBaseImpl { + return s.predictionDriftMetricThresholdBase +} + +func UnmarshalPredictionDriftMetricThresholdBaseImplementation(input []byte) (PredictionDriftMetricThresholdBase, 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 PredictionDriftMetricThresholdBase into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["dataType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Categorical") { + var out CategoricalPredictionDriftMetricThreshold + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CategoricalPredictionDriftMetricThreshold: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Numerical") { + var out NumericalPredictionDriftMetricThreshold + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into NumericalPredictionDriftMetricThreshold: %+v", err) + } + return out, nil + } + + var parent BasePredictionDriftMetricThresholdBaseImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BasePredictionDriftMetricThresholdBaseImpl: %+v", err) + } + + return RawPredictionDriftMetricThresholdBaseImpl{ + predictionDriftMetricThresholdBase: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_predictiondriftmonitoringsignal.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_predictiondriftmonitoringsignal.go new file mode 100644 index 00000000000..cb77d170c45 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_predictiondriftmonitoringsignal.go @@ -0,0 +1,116 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ MonitoringSignalBase = PredictionDriftMonitoringSignal{} + +type PredictionDriftMonitoringSignal struct { + FeatureDataTypeOverride *map[string]MonitoringFeatureDataType `json:"featureDataTypeOverride,omitempty"` + MetricThresholds []PredictionDriftMetricThresholdBase `json:"metricThresholds"` + ProductionData MonitoringInputDataBase `json:"productionData"` + ReferenceData MonitoringInputDataBase `json:"referenceData"` + + // Fields inherited from MonitoringSignalBase + + NotificationTypes *[]MonitoringNotificationType `json:"notificationTypes,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + SignalType MonitoringSignalType `json:"signalType"` +} + +func (s PredictionDriftMonitoringSignal) MonitoringSignalBase() BaseMonitoringSignalBaseImpl { + return BaseMonitoringSignalBaseImpl{ + NotificationTypes: s.NotificationTypes, + Properties: s.Properties, + SignalType: s.SignalType, + } +} + +var _ json.Marshaler = PredictionDriftMonitoringSignal{} + +func (s PredictionDriftMonitoringSignal) MarshalJSON() ([]byte, error) { + type wrapper PredictionDriftMonitoringSignal + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling PredictionDriftMonitoringSignal: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling PredictionDriftMonitoringSignal: %+v", err) + } + + decoded["signalType"] = "PredictionDrift" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling PredictionDriftMonitoringSignal: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &PredictionDriftMonitoringSignal{} + +func (s *PredictionDriftMonitoringSignal) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FeatureDataTypeOverride *map[string]MonitoringFeatureDataType `json:"featureDataTypeOverride,omitempty"` + NotificationTypes *[]MonitoringNotificationType `json:"notificationTypes,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + SignalType MonitoringSignalType `json:"signalType"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FeatureDataTypeOverride = decoded.FeatureDataTypeOverride + s.NotificationTypes = decoded.NotificationTypes + s.Properties = decoded.Properties + s.SignalType = decoded.SignalType + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling PredictionDriftMonitoringSignal into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["metricThresholds"]; ok { + var listTemp []json.RawMessage + if err := json.Unmarshal(v, &listTemp); err != nil { + return fmt.Errorf("unmarshaling MetricThresholds into list []json.RawMessage: %+v", err) + } + + output := make([]PredictionDriftMetricThresholdBase, 0) + for i, val := range listTemp { + impl, err := UnmarshalPredictionDriftMetricThresholdBaseImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling index %d field 'MetricThresholds' for 'PredictionDriftMonitoringSignal': %+v", i, err) + } + output = append(output, impl) + } + s.MetricThresholds = output + } + + if v, ok := temp["productionData"]; ok { + impl, err := UnmarshalMonitoringInputDataBaseImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ProductionData' for 'PredictionDriftMonitoringSignal': %+v", err) + } + s.ProductionData = impl + } + + if v, ok := temp["referenceData"]; ok { + impl, err := UnmarshalMonitoringInputDataBaseImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'ReferenceData' for 'PredictionDriftMonitoringSignal': %+v", err) + } + s.ReferenceData = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_pytorch.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_pytorch.go new file mode 100644 index 00000000000..0080d383d38 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_pytorch.go @@ -0,0 +1,50 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DistributionConfiguration = PyTorch{} + +type PyTorch struct { + ProcessCountPerInstance *int64 `json:"processCountPerInstance,omitempty"` + + // Fields inherited from DistributionConfiguration + + DistributionType DistributionType `json:"distributionType"` +} + +func (s PyTorch) DistributionConfiguration() BaseDistributionConfigurationImpl { + return BaseDistributionConfigurationImpl{ + DistributionType: s.DistributionType, + } +} + +var _ json.Marshaler = PyTorch{} + +func (s PyTorch) MarshalJSON() ([]byte, error) { + type wrapper PyTorch + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling PyTorch: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling PyTorch: %+v", err) + } + + decoded["distributionType"] = "PyTorch" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling PyTorch: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_queuesettings.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_queuesettings.go new file mode 100644 index 00000000000..64402e509f7 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_queuesettings.go @@ -0,0 +1,8 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type QueueSettings struct { + JobTier *JobTier `json:"jobTier,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_randomsamplingalgorithm.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_randomsamplingalgorithm.go new file mode 100644 index 00000000000..3380183918e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_randomsamplingalgorithm.go @@ -0,0 +1,51 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SamplingAlgorithm = RandomSamplingAlgorithm{} + +type RandomSamplingAlgorithm struct { + Rule *RandomSamplingAlgorithmRule `json:"rule,omitempty"` + Seed *int64 `json:"seed,omitempty"` + + // Fields inherited from SamplingAlgorithm + + SamplingAlgorithmType SamplingAlgorithmType `json:"samplingAlgorithmType"` +} + +func (s RandomSamplingAlgorithm) SamplingAlgorithm() BaseSamplingAlgorithmImpl { + return BaseSamplingAlgorithmImpl{ + SamplingAlgorithmType: s.SamplingAlgorithmType, + } +} + +var _ json.Marshaler = RandomSamplingAlgorithm{} + +func (s RandomSamplingAlgorithm) MarshalJSON() ([]byte, error) { + type wrapper RandomSamplingAlgorithm + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RandomSamplingAlgorithm: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RandomSamplingAlgorithm: %+v", err) + } + + decoded["samplingAlgorithmType"] = "Random" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RandomSamplingAlgorithm: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_recurrenceschedule.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_recurrenceschedule.go new file mode 100644 index 00000000000..90016cef3e5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_recurrenceschedule.go @@ -0,0 +1,11 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RecurrenceSchedule struct { + Hours []int64 `json:"hours"` + Minutes []int64 `json:"minutes"` + MonthDays *[]int64 `json:"monthDays,omitempty"` + WeekDays *[]WeekDay `json:"weekDays,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_recurrencetrigger.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_recurrencetrigger.go new file mode 100644 index 00000000000..83476eed9d2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_recurrencetrigger.go @@ -0,0 +1,58 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ TriggerBase = RecurrenceTrigger{} + +type RecurrenceTrigger struct { + Frequency RecurrenceFrequency `json:"frequency"` + Interval int64 `json:"interval"` + Schedule *RecurrenceSchedule `json:"schedule,omitempty"` + + // Fields inherited from TriggerBase + + EndTime *string `json:"endTime,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + TriggerType TriggerType `json:"triggerType"` +} + +func (s RecurrenceTrigger) TriggerBase() BaseTriggerBaseImpl { + return BaseTriggerBaseImpl{ + EndTime: s.EndTime, + StartTime: s.StartTime, + TimeZone: s.TimeZone, + TriggerType: s.TriggerType, + } +} + +var _ json.Marshaler = RecurrenceTrigger{} + +func (s RecurrenceTrigger) MarshalJSON() ([]byte, error) { + type wrapper RecurrenceTrigger + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RecurrenceTrigger: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RecurrenceTrigger: %+v", err) + } + + decoded["triggerType"] = "Recurrence" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RecurrenceTrigger: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_regression.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_regression.go new file mode 100644 index 00000000000..b4ad35e1c36 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_regression.go @@ -0,0 +1,120 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AutoMLVertical = Regression{} + +type Regression struct { + CvSplitColumnNames *[]string `json:"cvSplitColumnNames,omitempty"` + FeaturizationSettings *TableVerticalFeaturizationSettings `json:"featurizationSettings,omitempty"` + LimitSettings *TableVerticalLimitSettings `json:"limitSettings,omitempty"` + NCrossValidations NCrossValidations `json:"nCrossValidations"` + PrimaryMetric *RegressionPrimaryMetrics `json:"primaryMetric,omitempty"` + TestData *MLTableJobInput `json:"testData,omitempty"` + TestDataSize *float64 `json:"testDataSize,omitempty"` + TrainingSettings *RegressionTrainingSettings `json:"trainingSettings,omitempty"` + ValidationData *MLTableJobInput `json:"validationData,omitempty"` + ValidationDataSize *float64 `json:"validationDataSize,omitempty"` + WeightColumnName *string `json:"weightColumnName,omitempty"` + + // Fields inherited from AutoMLVertical + + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` +} + +func (s Regression) AutoMLVertical() BaseAutoMLVerticalImpl { + return BaseAutoMLVerticalImpl{ + LogVerbosity: s.LogVerbosity, + TargetColumnName: s.TargetColumnName, + TaskType: s.TaskType, + TrainingData: s.TrainingData, + } +} + +var _ json.Marshaler = Regression{} + +func (s Regression) MarshalJSON() ([]byte, error) { + type wrapper Regression + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling Regression: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling Regression: %+v", err) + } + + decoded["taskType"] = "Regression" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling Regression: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &Regression{} + +func (s *Regression) UnmarshalJSON(bytes []byte) error { + var decoded struct { + CvSplitColumnNames *[]string `json:"cvSplitColumnNames,omitempty"` + FeaturizationSettings *TableVerticalFeaturizationSettings `json:"featurizationSettings,omitempty"` + LimitSettings *TableVerticalLimitSettings `json:"limitSettings,omitempty"` + PrimaryMetric *RegressionPrimaryMetrics `json:"primaryMetric,omitempty"` + TestData *MLTableJobInput `json:"testData,omitempty"` + TestDataSize *float64 `json:"testDataSize,omitempty"` + TrainingSettings *RegressionTrainingSettings `json:"trainingSettings,omitempty"` + ValidationData *MLTableJobInput `json:"validationData,omitempty"` + ValidationDataSize *float64 `json:"validationDataSize,omitempty"` + WeightColumnName *string `json:"weightColumnName,omitempty"` + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.CvSplitColumnNames = decoded.CvSplitColumnNames + s.FeaturizationSettings = decoded.FeaturizationSettings + s.LimitSettings = decoded.LimitSettings + s.PrimaryMetric = decoded.PrimaryMetric + s.TestData = decoded.TestData + s.TestDataSize = decoded.TestDataSize + s.TrainingSettings = decoded.TrainingSettings + s.ValidationData = decoded.ValidationData + s.ValidationDataSize = decoded.ValidationDataSize + s.WeightColumnName = decoded.WeightColumnName + s.LogVerbosity = decoded.LogVerbosity + s.TargetColumnName = decoded.TargetColumnName + s.TaskType = decoded.TaskType + s.TrainingData = decoded.TrainingData + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling Regression into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["nCrossValidations"]; ok { + impl, err := UnmarshalNCrossValidationsImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'NCrossValidations' for 'Regression': %+v", err) + } + s.NCrossValidations = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_regressiontrainingsettings.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_regressiontrainingsettings.go new file mode 100644 index 00000000000..2d0ac239336 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_regressiontrainingsettings.go @@ -0,0 +1,16 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegressionTrainingSettings struct { + AllowedTrainingAlgorithms *[]RegressionModels `json:"allowedTrainingAlgorithms,omitempty"` + BlockedTrainingAlgorithms *[]RegressionModels `json:"blockedTrainingAlgorithms,omitempty"` + EnableDnnTraining *bool `json:"enableDnnTraining,omitempty"` + EnableModelExplainability *bool `json:"enableModelExplainability,omitempty"` + EnableOnnxCompatibleModels *bool `json:"enableOnnxCompatibleModels,omitempty"` + EnableStackEnsemble *bool `json:"enableStackEnsemble,omitempty"` + EnableVoteEnsemble *bool `json:"enableVoteEnsemble,omitempty"` + EnsembleModelDownloadTimeout *string `json:"ensembleModelDownloadTimeout,omitempty"` + StackEnsembleSettings *StackEnsembleSettings `json:"stackEnsembleSettings,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_rollinginputdata.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_rollinginputdata.go new file mode 100644 index 00000000000..d464aee793e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_rollinginputdata.go @@ -0,0 +1,60 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ MonitoringInputDataBase = RollingInputData{} + +type RollingInputData struct { + PreprocessingComponentId *string `json:"preprocessingComponentId,omitempty"` + WindowOffset string `json:"windowOffset"` + WindowSize string `json:"windowSize"` + + // Fields inherited from MonitoringInputDataBase + + Columns *map[string]string `json:"columns,omitempty"` + DataContext *string `json:"dataContext,omitempty"` + InputDataType MonitoringInputDataType `json:"inputDataType"` + JobInputType JobInputType `json:"jobInputType"` + Uri string `json:"uri"` +} + +func (s RollingInputData) MonitoringInputDataBase() BaseMonitoringInputDataBaseImpl { + return BaseMonitoringInputDataBaseImpl{ + Columns: s.Columns, + DataContext: s.DataContext, + InputDataType: s.InputDataType, + JobInputType: s.JobInputType, + Uri: s.Uri, + } +} + +var _ json.Marshaler = RollingInputData{} + +func (s RollingInputData) MarshalJSON() ([]byte, error) { + type wrapper RollingInputData + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling RollingInputData: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling RollingInputData: %+v", err) + } + + decoded["inputDataType"] = "Rolling" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling RollingInputData: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_samplingalgorithm.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_samplingalgorithm.go new file mode 100644 index 00000000000..66c88a44532 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_samplingalgorithm.go @@ -0,0 +1,91 @@ +package schedule + +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 SamplingAlgorithm interface { + SamplingAlgorithm() BaseSamplingAlgorithmImpl +} + +var _ SamplingAlgorithm = BaseSamplingAlgorithmImpl{} + +type BaseSamplingAlgorithmImpl struct { + SamplingAlgorithmType SamplingAlgorithmType `json:"samplingAlgorithmType"` +} + +func (s BaseSamplingAlgorithmImpl) SamplingAlgorithm() BaseSamplingAlgorithmImpl { + return s +} + +var _ SamplingAlgorithm = RawSamplingAlgorithmImpl{} + +// RawSamplingAlgorithmImpl 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 RawSamplingAlgorithmImpl struct { + samplingAlgorithm BaseSamplingAlgorithmImpl + Type string + Values map[string]interface{} +} + +func (s RawSamplingAlgorithmImpl) SamplingAlgorithm() BaseSamplingAlgorithmImpl { + return s.samplingAlgorithm +} + +func UnmarshalSamplingAlgorithmImplementation(input []byte) (SamplingAlgorithm, 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 SamplingAlgorithm into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["samplingAlgorithmType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Bayesian") { + var out BayesianSamplingAlgorithm + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into BayesianSamplingAlgorithm: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Grid") { + var out GridSamplingAlgorithm + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into GridSamplingAlgorithm: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Random") { + var out RandomSamplingAlgorithm + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RandomSamplingAlgorithm: %+v", err) + } + return out, nil + } + + var parent BaseSamplingAlgorithmImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseSamplingAlgorithmImpl: %+v", err) + } + + return RawSamplingAlgorithmImpl{ + samplingAlgorithm: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_schedule.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_schedule.go new file mode 100644 index 00000000000..4966dde2767 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_schedule.go @@ -0,0 +1,66 @@ +package schedule + +import ( + "encoding/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 Schedule struct { + Action ScheduleActionBase `json:"action"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + IsEnabled *bool `json:"isEnabled,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ProvisioningState *ScheduleProvisioningStatus `json:"provisioningState,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Trigger TriggerBase `json:"trigger"` +} + +var _ json.Unmarshaler = &Schedule{} + +func (s *Schedule) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + IsEnabled *bool `json:"isEnabled,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + ProvisioningState *ScheduleProvisioningStatus `json:"provisioningState,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Description = decoded.Description + s.DisplayName = decoded.DisplayName + s.IsEnabled = decoded.IsEnabled + s.Properties = decoded.Properties + s.ProvisioningState = decoded.ProvisioningState + s.Tags = decoded.Tags + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling Schedule into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["action"]; ok { + impl, err := UnmarshalScheduleActionBaseImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Action' for 'Schedule': %+v", err) + } + s.Action = impl + } + + if v, ok := temp["trigger"]; ok { + impl, err := UnmarshalTriggerBaseImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Trigger' for 'Schedule': %+v", err) + } + s.Trigger = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_scheduleactionbase.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_scheduleactionbase.go new file mode 100644 index 00000000000..27260e4c11f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_scheduleactionbase.go @@ -0,0 +1,91 @@ +package schedule + +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 ScheduleActionBase interface { + ScheduleActionBase() BaseScheduleActionBaseImpl +} + +var _ ScheduleActionBase = BaseScheduleActionBaseImpl{} + +type BaseScheduleActionBaseImpl struct { + ActionType ScheduleActionType `json:"actionType"` +} + +func (s BaseScheduleActionBaseImpl) ScheduleActionBase() BaseScheduleActionBaseImpl { + return s +} + +var _ ScheduleActionBase = RawScheduleActionBaseImpl{} + +// RawScheduleActionBaseImpl 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 RawScheduleActionBaseImpl struct { + scheduleActionBase BaseScheduleActionBaseImpl + Type string + Values map[string]interface{} +} + +func (s RawScheduleActionBaseImpl) ScheduleActionBase() BaseScheduleActionBaseImpl { + return s.scheduleActionBase +} + +func UnmarshalScheduleActionBaseImplementation(input []byte) (ScheduleActionBase, 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 ScheduleActionBase into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["actionType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "CreateMonitor") { + var out CreateMonitorAction + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CreateMonitorAction: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "InvokeBatchEndpoint") { + var out EndpointScheduleAction + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into EndpointScheduleAction: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "CreateJob") { + var out JobScheduleAction + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into JobScheduleAction: %+v", err) + } + return out, nil + } + + var parent BaseScheduleActionBaseImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseScheduleActionBaseImpl: %+v", err) + } + + return RawScheduleActionBaseImpl{ + scheduleActionBase: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_scheduleresource.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_scheduleresource.go new file mode 100644 index 00000000000..1a3a7800ede --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_scheduleresource.go @@ -0,0 +1,16 @@ +package schedule + +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 ScheduleResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties Schedule `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_seasonality.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_seasonality.go new file mode 100644 index 00000000000..b4cc989cff9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_seasonality.go @@ -0,0 +1,83 @@ +package schedule + +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 Seasonality interface { + Seasonality() BaseSeasonalityImpl +} + +var _ Seasonality = BaseSeasonalityImpl{} + +type BaseSeasonalityImpl struct { + Mode SeasonalityMode `json:"mode"` +} + +func (s BaseSeasonalityImpl) Seasonality() BaseSeasonalityImpl { + return s +} + +var _ Seasonality = RawSeasonalityImpl{} + +// RawSeasonalityImpl 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 RawSeasonalityImpl struct { + seasonality BaseSeasonalityImpl + Type string + Values map[string]interface{} +} + +func (s RawSeasonalityImpl) Seasonality() BaseSeasonalityImpl { + return s.seasonality +} + +func UnmarshalSeasonalityImplementation(input []byte) (Seasonality, 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 Seasonality into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["mode"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Auto") { + var out AutoSeasonality + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AutoSeasonality: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Custom") { + var out CustomSeasonality + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CustomSeasonality: %+v", err) + } + return out, nil + } + + var parent BaseSeasonalityImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseSeasonalityImpl: %+v", err) + } + + return RawSeasonalityImpl{ + seasonality: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_sparkjob.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_sparkjob.go new file mode 100644 index 00000000000..f0cec45873b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_sparkjob.go @@ -0,0 +1,201 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobBase = SparkJob{} + +type SparkJob struct { + Archives *[]string `json:"archives,omitempty"` + Args *string `json:"args,omitempty"` + CodeId string `json:"codeId"` + Conf *map[string]string `json:"conf,omitempty"` + Entry SparkJobEntry `json:"entry"` + EnvironmentId *string `json:"environmentId,omitempty"` + EnvironmentVariables *map[string]string `json:"environmentVariables,omitempty"` + Files *[]string `json:"files,omitempty"` + Inputs *map[string]JobInput `json:"inputs,omitempty"` + Jars *[]string `json:"jars,omitempty"` + Outputs *map[string]JobOutput `json:"outputs,omitempty"` + PyFiles *[]string `json:"pyFiles,omitempty"` + QueueSettings *QueueSettings `json:"queueSettings,omitempty"` + Resources *SparkResourceConfiguration `json:"resources,omitempty"` + + // Fields inherited from JobBase + + ComponentId *string `json:"componentId,omitempty"` + ComputeId *string `json:"computeId,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExperimentName *string `json:"experimentName,omitempty"` + Identity IdentityConfiguration `json:"identity"` + IsArchived *bool `json:"isArchived,omitempty"` + JobType JobType `json:"jobType"` + NotificationSetting *NotificationSetting `json:"notificationSetting,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Services *map[string]JobService `json:"services,omitempty"` + Status *JobStatus `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +func (s SparkJob) JobBase() BaseJobBaseImpl { + return BaseJobBaseImpl{ + ComponentId: s.ComponentId, + ComputeId: s.ComputeId, + Description: s.Description, + DisplayName: s.DisplayName, + ExperimentName: s.ExperimentName, + Identity: s.Identity, + IsArchived: s.IsArchived, + JobType: s.JobType, + NotificationSetting: s.NotificationSetting, + Properties: s.Properties, + Services: s.Services, + Status: s.Status, + Tags: s.Tags, + } +} + +var _ json.Marshaler = SparkJob{} + +func (s SparkJob) MarshalJSON() ([]byte, error) { + type wrapper SparkJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SparkJob: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SparkJob: %+v", err) + } + + decoded["jobType"] = "Spark" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SparkJob: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &SparkJob{} + +func (s *SparkJob) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Archives *[]string `json:"archives,omitempty"` + Args *string `json:"args,omitempty"` + CodeId string `json:"codeId"` + Conf *map[string]string `json:"conf,omitempty"` + EnvironmentId *string `json:"environmentId,omitempty"` + EnvironmentVariables *map[string]string `json:"environmentVariables,omitempty"` + Files *[]string `json:"files,omitempty"` + Jars *[]string `json:"jars,omitempty"` + PyFiles *[]string `json:"pyFiles,omitempty"` + QueueSettings *QueueSettings `json:"queueSettings,omitempty"` + Resources *SparkResourceConfiguration `json:"resources,omitempty"` + ComponentId *string `json:"componentId,omitempty"` + ComputeId *string `json:"computeId,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExperimentName *string `json:"experimentName,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + JobType JobType `json:"jobType"` + NotificationSetting *NotificationSetting `json:"notificationSetting,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Services *map[string]JobService `json:"services,omitempty"` + Status *JobStatus `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Archives = decoded.Archives + s.Args = decoded.Args + s.CodeId = decoded.CodeId + s.Conf = decoded.Conf + s.EnvironmentId = decoded.EnvironmentId + s.EnvironmentVariables = decoded.EnvironmentVariables + s.Files = decoded.Files + s.Jars = decoded.Jars + s.PyFiles = decoded.PyFiles + s.QueueSettings = decoded.QueueSettings + s.Resources = decoded.Resources + s.ComponentId = decoded.ComponentId + s.ComputeId = decoded.ComputeId + s.Description = decoded.Description + s.DisplayName = decoded.DisplayName + s.ExperimentName = decoded.ExperimentName + s.IsArchived = decoded.IsArchived + s.JobType = decoded.JobType + s.NotificationSetting = decoded.NotificationSetting + s.Properties = decoded.Properties + s.Services = decoded.Services + s.Status = decoded.Status + s.Tags = decoded.Tags + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling SparkJob into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["entry"]; ok { + impl, err := UnmarshalSparkJobEntryImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Entry' for 'SparkJob': %+v", err) + } + s.Entry = impl + } + + if v, ok := temp["identity"]; ok { + impl, err := UnmarshalIdentityConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Identity' for 'SparkJob': %+v", err) + } + s.Identity = impl + } + + if v, ok := temp["inputs"]; ok { + var dictionaryTemp map[string]json.RawMessage + if err := json.Unmarshal(v, &dictionaryTemp); err != nil { + return fmt.Errorf("unmarshaling Inputs into dictionary map[string]json.RawMessage: %+v", err) + } + + output := make(map[string]JobInput) + for key, val := range dictionaryTemp { + impl, err := UnmarshalJobInputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling key %q field 'Inputs' for 'SparkJob': %+v", key, err) + } + output[key] = impl + } + s.Inputs = &output + } + + if v, ok := temp["outputs"]; ok { + var dictionaryTemp map[string]json.RawMessage + if err := json.Unmarshal(v, &dictionaryTemp); err != nil { + return fmt.Errorf("unmarshaling Outputs into dictionary map[string]json.RawMessage: %+v", err) + } + + output := make(map[string]JobOutput) + for key, val := range dictionaryTemp { + impl, err := UnmarshalJobOutputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling key %q field 'Outputs' for 'SparkJob': %+v", key, err) + } + output[key] = impl + } + s.Outputs = &output + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_sparkjobentry.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_sparkjobentry.go new file mode 100644 index 00000000000..ebc92122084 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_sparkjobentry.go @@ -0,0 +1,83 @@ +package schedule + +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 SparkJobEntry interface { + SparkJobEntry() BaseSparkJobEntryImpl +} + +var _ SparkJobEntry = BaseSparkJobEntryImpl{} + +type BaseSparkJobEntryImpl struct { + SparkJobEntryType SparkJobEntryType `json:"sparkJobEntryType"` +} + +func (s BaseSparkJobEntryImpl) SparkJobEntry() BaseSparkJobEntryImpl { + return s +} + +var _ SparkJobEntry = RawSparkJobEntryImpl{} + +// RawSparkJobEntryImpl 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 RawSparkJobEntryImpl struct { + sparkJobEntry BaseSparkJobEntryImpl + Type string + Values map[string]interface{} +} + +func (s RawSparkJobEntryImpl) SparkJobEntry() BaseSparkJobEntryImpl { + return s.sparkJobEntry +} + +func UnmarshalSparkJobEntryImplementation(input []byte) (SparkJobEntry, 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 SparkJobEntry into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["sparkJobEntryType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "SparkJobPythonEntry") { + var out SparkJobPythonEntry + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SparkJobPythonEntry: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SparkJobScalaEntry") { + var out SparkJobScalaEntry + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SparkJobScalaEntry: %+v", err) + } + return out, nil + } + + var parent BaseSparkJobEntryImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseSparkJobEntryImpl: %+v", err) + } + + return RawSparkJobEntryImpl{ + sparkJobEntry: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_sparkjobpythonentry.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_sparkjobpythonentry.go new file mode 100644 index 00000000000..c2f27fda1d9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_sparkjobpythonentry.go @@ -0,0 +1,50 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SparkJobEntry = SparkJobPythonEntry{} + +type SparkJobPythonEntry struct { + File string `json:"file"` + + // Fields inherited from SparkJobEntry + + SparkJobEntryType SparkJobEntryType `json:"sparkJobEntryType"` +} + +func (s SparkJobPythonEntry) SparkJobEntry() BaseSparkJobEntryImpl { + return BaseSparkJobEntryImpl{ + SparkJobEntryType: s.SparkJobEntryType, + } +} + +var _ json.Marshaler = SparkJobPythonEntry{} + +func (s SparkJobPythonEntry) MarshalJSON() ([]byte, error) { + type wrapper SparkJobPythonEntry + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SparkJobPythonEntry: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SparkJobPythonEntry: %+v", err) + } + + decoded["sparkJobEntryType"] = "SparkJobPythonEntry" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SparkJobPythonEntry: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_sparkjobscalaentry.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_sparkjobscalaentry.go new file mode 100644 index 00000000000..7ed587540f6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_sparkjobscalaentry.go @@ -0,0 +1,50 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ SparkJobEntry = SparkJobScalaEntry{} + +type SparkJobScalaEntry struct { + ClassName string `json:"className"` + + // Fields inherited from SparkJobEntry + + SparkJobEntryType SparkJobEntryType `json:"sparkJobEntryType"` +} + +func (s SparkJobScalaEntry) SparkJobEntry() BaseSparkJobEntryImpl { + return BaseSparkJobEntryImpl{ + SparkJobEntryType: s.SparkJobEntryType, + } +} + +var _ json.Marshaler = SparkJobScalaEntry{} + +func (s SparkJobScalaEntry) MarshalJSON() ([]byte, error) { + type wrapper SparkJobScalaEntry + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SparkJobScalaEntry: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SparkJobScalaEntry: %+v", err) + } + + decoded["sparkJobEntryType"] = "SparkJobScalaEntry" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SparkJobScalaEntry: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_sparkresourceconfiguration.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_sparkresourceconfiguration.go new file mode 100644 index 00000000000..32964dde23b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_sparkresourceconfiguration.go @@ -0,0 +1,9 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SparkResourceConfiguration struct { + InstanceType *string `json:"instanceType,omitempty"` + RuntimeVersion *string `json:"runtimeVersion,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_stackensemblesettings.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_stackensemblesettings.go new file mode 100644 index 00000000000..199d503c01b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_stackensemblesettings.go @@ -0,0 +1,10 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type StackEnsembleSettings struct { + StackMetaLearnerKWargs *interface{} `json:"stackMetaLearnerKWargs,omitempty"` + StackMetaLearnerTrainPercentage *float64 `json:"stackMetaLearnerTrainPercentage,omitempty"` + StackMetaLearnerType *StackMetaLearnerType `json:"stackMetaLearnerType,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_staticinputdata.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_staticinputdata.go new file mode 100644 index 00000000000..62b8fd2eeb7 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_staticinputdata.go @@ -0,0 +1,60 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ MonitoringInputDataBase = StaticInputData{} + +type StaticInputData struct { + PreprocessingComponentId *string `json:"preprocessingComponentId,omitempty"` + WindowEnd string `json:"windowEnd"` + WindowStart string `json:"windowStart"` + + // Fields inherited from MonitoringInputDataBase + + Columns *map[string]string `json:"columns,omitempty"` + DataContext *string `json:"dataContext,omitempty"` + InputDataType MonitoringInputDataType `json:"inputDataType"` + JobInputType JobInputType `json:"jobInputType"` + Uri string `json:"uri"` +} + +func (s StaticInputData) MonitoringInputDataBase() BaseMonitoringInputDataBaseImpl { + return BaseMonitoringInputDataBaseImpl{ + Columns: s.Columns, + DataContext: s.DataContext, + InputDataType: s.InputDataType, + JobInputType: s.JobInputType, + Uri: s.Uri, + } +} + +var _ json.Marshaler = StaticInputData{} + +func (s StaticInputData) MarshalJSON() ([]byte, error) { + type wrapper StaticInputData + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling StaticInputData: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling StaticInputData: %+v", err) + } + + decoded["inputDataType"] = "Static" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling StaticInputData: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_sweepjob.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_sweepjob.go new file mode 100644 index 00000000000..e02722c9a43 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_sweepjob.go @@ -0,0 +1,192 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobBase = SweepJob{} + +type SweepJob struct { + EarlyTermination EarlyTerminationPolicy `json:"earlyTermination"` + Inputs *map[string]JobInput `json:"inputs,omitempty"` + Limits *SweepJobLimits `json:"limits,omitempty"` + Objective Objective `json:"objective"` + Outputs *map[string]JobOutput `json:"outputs,omitempty"` + QueueSettings *QueueSettings `json:"queueSettings,omitempty"` + SamplingAlgorithm SamplingAlgorithm `json:"samplingAlgorithm"` + SearchSpace interface{} `json:"searchSpace"` + Trial TrialComponent `json:"trial"` + + // Fields inherited from JobBase + + ComponentId *string `json:"componentId,omitempty"` + ComputeId *string `json:"computeId,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExperimentName *string `json:"experimentName,omitempty"` + Identity IdentityConfiguration `json:"identity"` + IsArchived *bool `json:"isArchived,omitempty"` + JobType JobType `json:"jobType"` + NotificationSetting *NotificationSetting `json:"notificationSetting,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Services *map[string]JobService `json:"services,omitempty"` + Status *JobStatus `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} + +func (s SweepJob) JobBase() BaseJobBaseImpl { + return BaseJobBaseImpl{ + ComponentId: s.ComponentId, + ComputeId: s.ComputeId, + Description: s.Description, + DisplayName: s.DisplayName, + ExperimentName: s.ExperimentName, + Identity: s.Identity, + IsArchived: s.IsArchived, + JobType: s.JobType, + NotificationSetting: s.NotificationSetting, + Properties: s.Properties, + Services: s.Services, + Status: s.Status, + Tags: s.Tags, + } +} + +var _ json.Marshaler = SweepJob{} + +func (s SweepJob) MarshalJSON() ([]byte, error) { + type wrapper SweepJob + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SweepJob: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SweepJob: %+v", err) + } + + decoded["jobType"] = "Sweep" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SweepJob: %+v", err) + } + + return encoded, nil +} + +var _ json.Unmarshaler = &SweepJob{} + +func (s *SweepJob) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Limits *SweepJobLimits `json:"limits,omitempty"` + Objective Objective `json:"objective"` + QueueSettings *QueueSettings `json:"queueSettings,omitempty"` + SearchSpace interface{} `json:"searchSpace"` + Trial TrialComponent `json:"trial"` + ComponentId *string `json:"componentId,omitempty"` + ComputeId *string `json:"computeId,omitempty"` + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + ExperimentName *string `json:"experimentName,omitempty"` + IsArchived *bool `json:"isArchived,omitempty"` + JobType JobType `json:"jobType"` + NotificationSetting *NotificationSetting `json:"notificationSetting,omitempty"` + Properties *map[string]string `json:"properties,omitempty"` + Services *map[string]JobService `json:"services,omitempty"` + Status *JobStatus `json:"status,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Limits = decoded.Limits + s.Objective = decoded.Objective + s.QueueSettings = decoded.QueueSettings + s.SearchSpace = decoded.SearchSpace + s.Trial = decoded.Trial + s.ComponentId = decoded.ComponentId + s.ComputeId = decoded.ComputeId + s.Description = decoded.Description + s.DisplayName = decoded.DisplayName + s.ExperimentName = decoded.ExperimentName + s.IsArchived = decoded.IsArchived + s.JobType = decoded.JobType + s.NotificationSetting = decoded.NotificationSetting + s.Properties = decoded.Properties + s.Services = decoded.Services + s.Status = decoded.Status + s.Tags = decoded.Tags + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling SweepJob into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["earlyTermination"]; ok { + impl, err := UnmarshalEarlyTerminationPolicyImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'EarlyTermination' for 'SweepJob': %+v", err) + } + s.EarlyTermination = impl + } + + if v, ok := temp["identity"]; ok { + impl, err := UnmarshalIdentityConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Identity' for 'SweepJob': %+v", err) + } + s.Identity = impl + } + + if v, ok := temp["inputs"]; ok { + var dictionaryTemp map[string]json.RawMessage + if err := json.Unmarshal(v, &dictionaryTemp); err != nil { + return fmt.Errorf("unmarshaling Inputs into dictionary map[string]json.RawMessage: %+v", err) + } + + output := make(map[string]JobInput) + for key, val := range dictionaryTemp { + impl, err := UnmarshalJobInputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling key %q field 'Inputs' for 'SweepJob': %+v", key, err) + } + output[key] = impl + } + s.Inputs = &output + } + + if v, ok := temp["outputs"]; ok { + var dictionaryTemp map[string]json.RawMessage + if err := json.Unmarshal(v, &dictionaryTemp); err != nil { + return fmt.Errorf("unmarshaling Outputs into dictionary map[string]json.RawMessage: %+v", err) + } + + output := make(map[string]JobOutput) + for key, val := range dictionaryTemp { + impl, err := UnmarshalJobOutputImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling key %q field 'Outputs' for 'SweepJob': %+v", key, err) + } + output[key] = impl + } + s.Outputs = &output + } + + if v, ok := temp["samplingAlgorithm"]; ok { + impl, err := UnmarshalSamplingAlgorithmImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'SamplingAlgorithm' for 'SweepJob': %+v", err) + } + s.SamplingAlgorithm = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_sweepjoblimits.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_sweepjoblimits.go new file mode 100644 index 00000000000..5784a1c4cf3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_sweepjoblimits.go @@ -0,0 +1,54 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobLimits = SweepJobLimits{} + +type SweepJobLimits struct { + MaxConcurrentTrials *int64 `json:"maxConcurrentTrials,omitempty"` + MaxTotalTrials *int64 `json:"maxTotalTrials,omitempty"` + TrialTimeout *string `json:"trialTimeout,omitempty"` + + // Fields inherited from JobLimits + + JobLimitsType JobLimitsType `json:"jobLimitsType"` + Timeout *string `json:"timeout,omitempty"` +} + +func (s SweepJobLimits) JobLimits() BaseJobLimitsImpl { + return BaseJobLimitsImpl{ + JobLimitsType: s.JobLimitsType, + Timeout: s.Timeout, + } +} + +var _ json.Marshaler = SweepJobLimits{} + +func (s SweepJobLimits) MarshalJSON() ([]byte, error) { + type wrapper SweepJobLimits + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SweepJobLimits: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SweepJobLimits: %+v", err) + } + + decoded["jobLimitsType"] = "Sweep" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SweepJobLimits: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_tableverticalfeaturizationsettings.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_tableverticalfeaturizationsettings.go new file mode 100644 index 00000000000..68355fa6160 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_tableverticalfeaturizationsettings.go @@ -0,0 +1,13 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TableVerticalFeaturizationSettings struct { + BlockedTransformers *[]BlockedTransformers `json:"blockedTransformers,omitempty"` + ColumnNameAndTypes *map[string]string `json:"columnNameAndTypes,omitempty"` + DatasetLanguage *string `json:"datasetLanguage,omitempty"` + EnableDnnFeaturization *bool `json:"enableDnnFeaturization,omitempty"` + Mode *FeaturizationMode `json:"mode,omitempty"` + TransformerParams *map[string][]ColumnTransformer `json:"transformerParams,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_tableverticallimitsettings.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_tableverticallimitsettings.go new file mode 100644 index 00000000000..92aa9931df6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_tableverticallimitsettings.go @@ -0,0 +1,14 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type TableVerticalLimitSettings struct { + EnableEarlyTermination *bool `json:"enableEarlyTermination,omitempty"` + ExitScore *float64 `json:"exitScore,omitempty"` + MaxConcurrentTrials *int64 `json:"maxConcurrentTrials,omitempty"` + MaxCoresPerTrial *int64 `json:"maxCoresPerTrial,omitempty"` + MaxTrials *int64 `json:"maxTrials,omitempty"` + Timeout *string `json:"timeout,omitempty"` + TrialTimeout *string `json:"trialTimeout,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_targetlags.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_targetlags.go new file mode 100644 index 00000000000..1996dd8b4b2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_targetlags.go @@ -0,0 +1,83 @@ +package schedule + +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 TargetLags interface { + TargetLags() BaseTargetLagsImpl +} + +var _ TargetLags = BaseTargetLagsImpl{} + +type BaseTargetLagsImpl struct { + Mode TargetLagsMode `json:"mode"` +} + +func (s BaseTargetLagsImpl) TargetLags() BaseTargetLagsImpl { + return s +} + +var _ TargetLags = RawTargetLagsImpl{} + +// RawTargetLagsImpl 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 RawTargetLagsImpl struct { + targetLags BaseTargetLagsImpl + Type string + Values map[string]interface{} +} + +func (s RawTargetLagsImpl) TargetLags() BaseTargetLagsImpl { + return s.targetLags +} + +func UnmarshalTargetLagsImplementation(input []byte) (TargetLags, 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 TargetLags into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["mode"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Auto") { + var out AutoTargetLags + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AutoTargetLags: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Custom") { + var out CustomTargetLags + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CustomTargetLags: %+v", err) + } + return out, nil + } + + var parent BaseTargetLagsImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseTargetLagsImpl: %+v", err) + } + + return RawTargetLagsImpl{ + targetLags: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_targetrollingwindowsize.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_targetrollingwindowsize.go new file mode 100644 index 00000000000..97ce4d666e3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_targetrollingwindowsize.go @@ -0,0 +1,83 @@ +package schedule + +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 TargetRollingWindowSize interface { + TargetRollingWindowSize() BaseTargetRollingWindowSizeImpl +} + +var _ TargetRollingWindowSize = BaseTargetRollingWindowSizeImpl{} + +type BaseTargetRollingWindowSizeImpl struct { + Mode TargetRollingWindowSizeMode `json:"mode"` +} + +func (s BaseTargetRollingWindowSizeImpl) TargetRollingWindowSize() BaseTargetRollingWindowSizeImpl { + return s +} + +var _ TargetRollingWindowSize = RawTargetRollingWindowSizeImpl{} + +// RawTargetRollingWindowSizeImpl 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 RawTargetRollingWindowSizeImpl struct { + targetRollingWindowSize BaseTargetRollingWindowSizeImpl + Type string + Values map[string]interface{} +} + +func (s RawTargetRollingWindowSizeImpl) TargetRollingWindowSize() BaseTargetRollingWindowSizeImpl { + return s.targetRollingWindowSize +} + +func UnmarshalTargetRollingWindowSizeImplementation(input []byte) (TargetRollingWindowSize, 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 TargetRollingWindowSize into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["mode"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Auto") { + var out AutoTargetRollingWindowSize + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AutoTargetRollingWindowSize: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Custom") { + var out CustomTargetRollingWindowSize + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CustomTargetRollingWindowSize: %+v", err) + } + return out, nil + } + + var parent BaseTargetRollingWindowSizeImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseTargetRollingWindowSizeImpl: %+v", err) + } + + return RawTargetRollingWindowSizeImpl{ + targetRollingWindowSize: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_tensorflow.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_tensorflow.go new file mode 100644 index 00000000000..0aa30ef2b8d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_tensorflow.go @@ -0,0 +1,51 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ DistributionConfiguration = TensorFlow{} + +type TensorFlow struct { + ParameterServerCount *int64 `json:"parameterServerCount,omitempty"` + WorkerCount *int64 `json:"workerCount,omitempty"` + + // Fields inherited from DistributionConfiguration + + DistributionType DistributionType `json:"distributionType"` +} + +func (s TensorFlow) DistributionConfiguration() BaseDistributionConfigurationImpl { + return BaseDistributionConfigurationImpl{ + DistributionType: s.DistributionType, + } +} + +var _ json.Marshaler = TensorFlow{} + +func (s TensorFlow) MarshalJSON() ([]byte, error) { + type wrapper TensorFlow + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling TensorFlow: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling TensorFlow: %+v", err) + } + + decoded["distributionType"] = "TensorFlow" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling TensorFlow: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_textclassification.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_textclassification.go new file mode 100644 index 00000000000..2b0b698d039 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_textclassification.go @@ -0,0 +1,59 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AutoMLVertical = TextClassification{} + +type TextClassification struct { + FeaturizationSettings *FeaturizationSettings `json:"featurizationSettings,omitempty"` + LimitSettings *NlpVerticalLimitSettings `json:"limitSettings,omitempty"` + PrimaryMetric *ClassificationPrimaryMetrics `json:"primaryMetric,omitempty"` + ValidationData *MLTableJobInput `json:"validationData,omitempty"` + + // Fields inherited from AutoMLVertical + + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` +} + +func (s TextClassification) AutoMLVertical() BaseAutoMLVerticalImpl { + return BaseAutoMLVerticalImpl{ + LogVerbosity: s.LogVerbosity, + TargetColumnName: s.TargetColumnName, + TaskType: s.TaskType, + TrainingData: s.TrainingData, + } +} + +var _ json.Marshaler = TextClassification{} + +func (s TextClassification) MarshalJSON() ([]byte, error) { + type wrapper TextClassification + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling TextClassification: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling TextClassification: %+v", err) + } + + decoded["taskType"] = "TextClassification" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling TextClassification: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_textclassificationmultilabel.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_textclassificationmultilabel.go new file mode 100644 index 00000000000..8b125d0d634 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_textclassificationmultilabel.go @@ -0,0 +1,59 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AutoMLVertical = TextClassificationMultilabel{} + +type TextClassificationMultilabel struct { + FeaturizationSettings *FeaturizationSettings `json:"featurizationSettings,omitempty"` + LimitSettings *NlpVerticalLimitSettings `json:"limitSettings,omitempty"` + PrimaryMetric *ClassificationMultilabelPrimaryMetrics `json:"primaryMetric,omitempty"` + ValidationData *MLTableJobInput `json:"validationData,omitempty"` + + // Fields inherited from AutoMLVertical + + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` +} + +func (s TextClassificationMultilabel) AutoMLVertical() BaseAutoMLVerticalImpl { + return BaseAutoMLVerticalImpl{ + LogVerbosity: s.LogVerbosity, + TargetColumnName: s.TargetColumnName, + TaskType: s.TaskType, + TrainingData: s.TrainingData, + } +} + +var _ json.Marshaler = TextClassificationMultilabel{} + +func (s TextClassificationMultilabel) MarshalJSON() ([]byte, error) { + type wrapper TextClassificationMultilabel + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling TextClassificationMultilabel: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling TextClassificationMultilabel: %+v", err) + } + + decoded["taskType"] = "TextClassificationMultilabel" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling TextClassificationMultilabel: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_textner.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_textner.go new file mode 100644 index 00000000000..c28ae2fb0ab --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_textner.go @@ -0,0 +1,59 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ AutoMLVertical = TextNer{} + +type TextNer struct { + FeaturizationSettings *FeaturizationSettings `json:"featurizationSettings,omitempty"` + LimitSettings *NlpVerticalLimitSettings `json:"limitSettings,omitempty"` + PrimaryMetric *ClassificationPrimaryMetrics `json:"primaryMetric,omitempty"` + ValidationData *MLTableJobInput `json:"validationData,omitempty"` + + // Fields inherited from AutoMLVertical + + LogVerbosity *LogVerbosity `json:"logVerbosity,omitempty"` + TargetColumnName *string `json:"targetColumnName,omitempty"` + TaskType TaskType `json:"taskType"` + TrainingData MLTableJobInput `json:"trainingData"` +} + +func (s TextNer) AutoMLVertical() BaseAutoMLVerticalImpl { + return BaseAutoMLVerticalImpl{ + LogVerbosity: s.LogVerbosity, + TargetColumnName: s.TargetColumnName, + TaskType: s.TaskType, + TrainingData: s.TrainingData, + } +} + +var _ json.Marshaler = TextNer{} + +func (s TextNer) MarshalJSON() ([]byte, error) { + type wrapper TextNer + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling TextNer: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling TextNer: %+v", err) + } + + decoded["taskType"] = "TextNER" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling TextNer: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_topnfeaturesbyattribution.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_topnfeaturesbyattribution.go new file mode 100644 index 00000000000..a1deedf888c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_topnfeaturesbyattribution.go @@ -0,0 +1,50 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ MonitoringFeatureFilterBase = TopNFeaturesByAttribution{} + +type TopNFeaturesByAttribution struct { + Top *int64 `json:"top,omitempty"` + + // Fields inherited from MonitoringFeatureFilterBase + + FilterType MonitoringFeatureFilterType `json:"filterType"` +} + +func (s TopNFeaturesByAttribution) MonitoringFeatureFilterBase() BaseMonitoringFeatureFilterBaseImpl { + return BaseMonitoringFeatureFilterBaseImpl{ + FilterType: s.FilterType, + } +} + +var _ json.Marshaler = TopNFeaturesByAttribution{} + +func (s TopNFeaturesByAttribution) MarshalJSON() ([]byte, error) { + type wrapper TopNFeaturesByAttribution + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling TopNFeaturesByAttribution: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling TopNFeaturesByAttribution: %+v", err) + } + + decoded["filterType"] = "TopNByAttribution" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling TopNFeaturesByAttribution: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_trialcomponent.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_trialcomponent.go new file mode 100644 index 00000000000..6b13128060d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_trialcomponent.go @@ -0,0 +1,54 @@ +package schedule + +import ( + "encoding/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 TrialComponent struct { + CodeId *string `json:"codeId,omitempty"` + Command string `json:"command"` + Distribution DistributionConfiguration `json:"distribution"` + EnvironmentId string `json:"environmentId"` + EnvironmentVariables *map[string]string `json:"environmentVariables,omitempty"` + Resources *JobResourceConfiguration `json:"resources,omitempty"` +} + +var _ json.Unmarshaler = &TrialComponent{} + +func (s *TrialComponent) UnmarshalJSON(bytes []byte) error { + var decoded struct { + CodeId *string `json:"codeId,omitempty"` + Command string `json:"command"` + EnvironmentId string `json:"environmentId"` + EnvironmentVariables *map[string]string `json:"environmentVariables,omitempty"` + Resources *JobResourceConfiguration `json:"resources,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.CodeId = decoded.CodeId + s.Command = decoded.Command + s.EnvironmentId = decoded.EnvironmentId + s.EnvironmentVariables = decoded.EnvironmentVariables + s.Resources = decoded.Resources + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling TrialComponent into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["distribution"]; ok { + impl, err := UnmarshalDistributionConfigurationImplementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Distribution' for 'TrialComponent': %+v", err) + } + s.Distribution = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_triggerbase.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_triggerbase.go new file mode 100644 index 00000000000..64555e04e4d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_triggerbase.go @@ -0,0 +1,86 @@ +package schedule + +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 TriggerBase interface { + TriggerBase() BaseTriggerBaseImpl +} + +var _ TriggerBase = BaseTriggerBaseImpl{} + +type BaseTriggerBaseImpl struct { + EndTime *string `json:"endTime,omitempty"` + StartTime *string `json:"startTime,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + TriggerType TriggerType `json:"triggerType"` +} + +func (s BaseTriggerBaseImpl) TriggerBase() BaseTriggerBaseImpl { + return s +} + +var _ TriggerBase = RawTriggerBaseImpl{} + +// RawTriggerBaseImpl 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 RawTriggerBaseImpl struct { + triggerBase BaseTriggerBaseImpl + Type string + Values map[string]interface{} +} + +func (s RawTriggerBaseImpl) TriggerBase() BaseTriggerBaseImpl { + return s.triggerBase +} + +func UnmarshalTriggerBaseImplementation(input []byte) (TriggerBase, 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 TriggerBase into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["triggerType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "Cron") { + var out CronTrigger + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CronTrigger: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "Recurrence") { + var out RecurrenceTrigger + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into RecurrenceTrigger: %+v", err) + } + return out, nil + } + + var parent BaseTriggerBaseImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseTriggerBaseImpl: %+v", err) + } + + return RawTriggerBaseImpl{ + triggerBase: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_tritonmodeljobinput.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_tritonmodeljobinput.go new file mode 100644 index 00000000000..8b70c4466f0 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_tritonmodeljobinput.go @@ -0,0 +1,53 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobInput = TritonModelJobInput{} + +type TritonModelJobInput struct { + Mode *InputDeliveryMode `json:"mode,omitempty"` + Uri string `json:"uri"` + + // Fields inherited from JobInput + + Description *string `json:"description,omitempty"` + JobInputType JobInputType `json:"jobInputType"` +} + +func (s TritonModelJobInput) JobInput() BaseJobInputImpl { + return BaseJobInputImpl{ + Description: s.Description, + JobInputType: s.JobInputType, + } +} + +var _ json.Marshaler = TritonModelJobInput{} + +func (s TritonModelJobInput) MarshalJSON() ([]byte, error) { + type wrapper TritonModelJobInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling TritonModelJobInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling TritonModelJobInput: %+v", err) + } + + decoded["jobInputType"] = "triton_model" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling TritonModelJobInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_tritonmodeljoboutput.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_tritonmodeljoboutput.go new file mode 100644 index 00000000000..6de11b4b5e8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_tritonmodeljoboutput.go @@ -0,0 +1,53 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobOutput = TritonModelJobOutput{} + +type TritonModelJobOutput struct { + Mode *OutputDeliveryMode `json:"mode,omitempty"` + Uri *string `json:"uri,omitempty"` + + // Fields inherited from JobOutput + + Description *string `json:"description,omitempty"` + JobOutputType JobOutputType `json:"jobOutputType"` +} + +func (s TritonModelJobOutput) JobOutput() BaseJobOutputImpl { + return BaseJobOutputImpl{ + Description: s.Description, + JobOutputType: s.JobOutputType, + } +} + +var _ json.Marshaler = TritonModelJobOutput{} + +func (s TritonModelJobOutput) MarshalJSON() ([]byte, error) { + type wrapper TritonModelJobOutput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling TritonModelJobOutput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling TritonModelJobOutput: %+v", err) + } + + decoded["jobOutputType"] = "triton_model" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling TritonModelJobOutput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_truncationselectionpolicy.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_truncationselectionpolicy.go new file mode 100644 index 00000000000..16f731bc40f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_truncationselectionpolicy.go @@ -0,0 +1,54 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ EarlyTerminationPolicy = TruncationSelectionPolicy{} + +type TruncationSelectionPolicy struct { + TruncationPercentage *int64 `json:"truncationPercentage,omitempty"` + + // Fields inherited from EarlyTerminationPolicy + + DelayEvaluation *int64 `json:"delayEvaluation,omitempty"` + EvaluationInterval *int64 `json:"evaluationInterval,omitempty"` + PolicyType EarlyTerminationPolicyType `json:"policyType"` +} + +func (s TruncationSelectionPolicy) EarlyTerminationPolicy() BaseEarlyTerminationPolicyImpl { + return BaseEarlyTerminationPolicyImpl{ + DelayEvaluation: s.DelayEvaluation, + EvaluationInterval: s.EvaluationInterval, + PolicyType: s.PolicyType, + } +} + +var _ json.Marshaler = TruncationSelectionPolicy{} + +func (s TruncationSelectionPolicy) MarshalJSON() ([]byte, error) { + type wrapper TruncationSelectionPolicy + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling TruncationSelectionPolicy: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling TruncationSelectionPolicy: %+v", err) + } + + decoded["policyType"] = "TruncationSelection" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling TruncationSelectionPolicy: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_urifilejobinput.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_urifilejobinput.go new file mode 100644 index 00000000000..1d1a59f9468 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_urifilejobinput.go @@ -0,0 +1,53 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobInput = UriFileJobInput{} + +type UriFileJobInput struct { + Mode *InputDeliveryMode `json:"mode,omitempty"` + Uri string `json:"uri"` + + // Fields inherited from JobInput + + Description *string `json:"description,omitempty"` + JobInputType JobInputType `json:"jobInputType"` +} + +func (s UriFileJobInput) JobInput() BaseJobInputImpl { + return BaseJobInputImpl{ + Description: s.Description, + JobInputType: s.JobInputType, + } +} + +var _ json.Marshaler = UriFileJobInput{} + +func (s UriFileJobInput) MarshalJSON() ([]byte, error) { + type wrapper UriFileJobInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling UriFileJobInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling UriFileJobInput: %+v", err) + } + + decoded["jobInputType"] = "uri_file" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling UriFileJobInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_urifilejoboutput.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_urifilejoboutput.go new file mode 100644 index 00000000000..b136431372e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_urifilejoboutput.go @@ -0,0 +1,53 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobOutput = UriFileJobOutput{} + +type UriFileJobOutput struct { + Mode *OutputDeliveryMode `json:"mode,omitempty"` + Uri *string `json:"uri,omitempty"` + + // Fields inherited from JobOutput + + Description *string `json:"description,omitempty"` + JobOutputType JobOutputType `json:"jobOutputType"` +} + +func (s UriFileJobOutput) JobOutput() BaseJobOutputImpl { + return BaseJobOutputImpl{ + Description: s.Description, + JobOutputType: s.JobOutputType, + } +} + +var _ json.Marshaler = UriFileJobOutput{} + +func (s UriFileJobOutput) MarshalJSON() ([]byte, error) { + type wrapper UriFileJobOutput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling UriFileJobOutput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling UriFileJobOutput: %+v", err) + } + + decoded["jobOutputType"] = "uri_file" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling UriFileJobOutput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_urifolderjobinput.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_urifolderjobinput.go new file mode 100644 index 00000000000..a13e02468b1 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_urifolderjobinput.go @@ -0,0 +1,53 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobInput = UriFolderJobInput{} + +type UriFolderJobInput struct { + Mode *InputDeliveryMode `json:"mode,omitempty"` + Uri string `json:"uri"` + + // Fields inherited from JobInput + + Description *string `json:"description,omitempty"` + JobInputType JobInputType `json:"jobInputType"` +} + +func (s UriFolderJobInput) JobInput() BaseJobInputImpl { + return BaseJobInputImpl{ + Description: s.Description, + JobInputType: s.JobInputType, + } +} + +var _ json.Marshaler = UriFolderJobInput{} + +func (s UriFolderJobInput) MarshalJSON() ([]byte, error) { + type wrapper UriFolderJobInput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling UriFolderJobInput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling UriFolderJobInput: %+v", err) + } + + decoded["jobInputType"] = "uri_folder" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling UriFolderJobInput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_urifolderjoboutput.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_urifolderjoboutput.go new file mode 100644 index 00000000000..4d651c86f9e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_urifolderjoboutput.go @@ -0,0 +1,53 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ JobOutput = UriFolderJobOutput{} + +type UriFolderJobOutput struct { + Mode *OutputDeliveryMode `json:"mode,omitempty"` + Uri *string `json:"uri,omitempty"` + + // Fields inherited from JobOutput + + Description *string `json:"description,omitempty"` + JobOutputType JobOutputType `json:"jobOutputType"` +} + +func (s UriFolderJobOutput) JobOutput() BaseJobOutputImpl { + return BaseJobOutputImpl{ + Description: s.Description, + JobOutputType: s.JobOutputType, + } +} + +var _ json.Marshaler = UriFolderJobOutput{} + +func (s UriFolderJobOutput) MarshalJSON() ([]byte, error) { + type wrapper UriFolderJobOutput + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling UriFolderJobOutput: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling UriFolderJobOutput: %+v", err) + } + + decoded["jobOutputType"] = "uri_folder" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling UriFolderJobOutput: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_useridentity.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_useridentity.go new file mode 100644 index 00000000000..4871dca1b51 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_useridentity.go @@ -0,0 +1,49 @@ +package schedule + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ IdentityConfiguration = UserIdentity{} + +type UserIdentity struct { + + // Fields inherited from IdentityConfiguration + + IdentityType IdentityConfigurationType `json:"identityType"` +} + +func (s UserIdentity) IdentityConfiguration() BaseIdentityConfigurationImpl { + return BaseIdentityConfigurationImpl{ + IdentityType: s.IdentityType, + } +} + +var _ json.Marshaler = UserIdentity{} + +func (s UserIdentity) MarshalJSON() ([]byte, error) { + type wrapper UserIdentity + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling UserIdentity: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling UserIdentity: %+v", err) + } + + decoded["identityType"] = "UserIdentity" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling UserIdentity: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/model_webhook.go b/resource-manager/machinelearningservices/2025-04-01/schedule/model_webhook.go new file mode 100644 index 00000000000..53cb621a0ad --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/model_webhook.go @@ -0,0 +1,76 @@ +package schedule + +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 Webhook interface { + Webhook() BaseWebhookImpl +} + +var _ Webhook = BaseWebhookImpl{} + +type BaseWebhookImpl struct { + EventType *string `json:"eventType,omitempty"` + WebhookType WebhookType `json:"webhookType"` +} + +func (s BaseWebhookImpl) Webhook() BaseWebhookImpl { + return s +} + +var _ Webhook = RawWebhookImpl{} + +// RawWebhookImpl 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 RawWebhookImpl struct { + webhook BaseWebhookImpl + Type string + Values map[string]interface{} +} + +func (s RawWebhookImpl) Webhook() BaseWebhookImpl { + return s.webhook +} + +func UnmarshalWebhookImplementation(input []byte) (Webhook, 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 Webhook into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["webhookType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AzureDevOps") { + var out AzureDevOpsWebhook + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AzureDevOpsWebhook: %+v", err) + } + return out, nil + } + + var parent BaseWebhookImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseWebhookImpl: %+v", err) + } + + return RawWebhookImpl{ + webhook: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/schedule/predicates.go b/resource-manager/machinelearningservices/2025-04-01/schedule/predicates.go new file mode 100644 index 00000000000..25e4b3c469f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/predicates.go @@ -0,0 +1,27 @@ +package schedule + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ScheduleResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p ScheduleResourceOperationPredicate) Matches(input ScheduleResource) 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/machinelearningservices/2025-04-01/schedule/version.go b/resource-manager/machinelearningservices/2025-04-01/schedule/version.go new file mode 100644 index 00000000000..324e343d017 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/schedule/version.go @@ -0,0 +1,10 @@ +package schedule + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/schedule/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/README.md b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/README.md new file mode 100644 index 00000000000..45c80964c21 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/README.md @@ -0,0 +1,132 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint` Documentation + +The `serverlessendpoint` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint" +``` + + +### Client Initialization + +```go +client := serverlessendpoint.NewServerlessEndpointClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `ServerlessEndpointClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := serverlessendpoint.NewServerlessEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "serverlessEndpointName") + +payload := serverlessendpoint.ServerlessEndpointTrackedResource{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ServerlessEndpointClient.Delete` + +```go +ctx := context.TODO() +id := serverlessendpoint.NewServerlessEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "serverlessEndpointName") + +if err := client.DeleteThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `ServerlessEndpointClient.Get` + +```go +ctx := context.TODO() +id := serverlessendpoint.NewServerlessEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "serverlessEndpointName") + +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: `ServerlessEndpointClient.List` + +```go +ctx := context.TODO() +id := serverlessendpoint.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +// alternatively `client.List(ctx, id, serverlessendpoint.DefaultListOperationOptions())` can be used to do batched pagination +items, err := client.ListComplete(ctx, id, serverlessendpoint.DefaultListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `ServerlessEndpointClient.ListKeys` + +```go +ctx := context.TODO() +id := serverlessendpoint.NewServerlessEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "serverlessEndpointName") + +read, err := client.ListKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `ServerlessEndpointClient.RegenerateKeys` + +```go +ctx := context.TODO() +id := serverlessendpoint.NewServerlessEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "serverlessEndpointName") + +payload := serverlessendpoint.RegenerateEndpointKeysRequest{ + // ... +} + + +if err := client.RegenerateKeysThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `ServerlessEndpointClient.Update` + +```go +ctx := context.TODO() +id := serverlessendpoint.NewServerlessEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "serverlessEndpointName") + +payload := serverlessendpoint.PartialMinimalTrackedResourceWithSkuAndIdentity{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/client.go b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/client.go new file mode 100644 index 00000000000..0ef60316cf4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/client.go @@ -0,0 +1,26 @@ +package serverlessendpoint + +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 ServerlessEndpointClient struct { + Client *resourcemanager.Client +} + +func NewServerlessEndpointClientWithBaseURI(sdkApi sdkEnv.Api) (*ServerlessEndpointClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "serverlessendpoint", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ServerlessEndpointClient: %+v", err) + } + + return &ServerlessEndpointClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/constants.go b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/constants.go new file mode 100644 index 00000000000..fdea21a1f22 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/constants.go @@ -0,0 +1,339 @@ +package serverlessendpoint + +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 ContentSafetyStatus string + +const ( + ContentSafetyStatusDisabled ContentSafetyStatus = "Disabled" + ContentSafetyStatusEnabled ContentSafetyStatus = "Enabled" +) + +func PossibleValuesForContentSafetyStatus() []string { + return []string{ + string(ContentSafetyStatusDisabled), + string(ContentSafetyStatusEnabled), + } +} + +func (s *ContentSafetyStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseContentSafetyStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseContentSafetyStatus(input string) (*ContentSafetyStatus, error) { + vals := map[string]ContentSafetyStatus{ + "disabled": ContentSafetyStatusDisabled, + "enabled": ContentSafetyStatusEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ContentSafetyStatus(input) + return &out, nil +} + +type EndpointProvisioningState string + +const ( + EndpointProvisioningStateCanceled EndpointProvisioningState = "Canceled" + EndpointProvisioningStateCreating EndpointProvisioningState = "Creating" + EndpointProvisioningStateDeleting EndpointProvisioningState = "Deleting" + EndpointProvisioningStateFailed EndpointProvisioningState = "Failed" + EndpointProvisioningStateSucceeded EndpointProvisioningState = "Succeeded" + EndpointProvisioningStateUpdating EndpointProvisioningState = "Updating" +) + +func PossibleValuesForEndpointProvisioningState() []string { + return []string{ + string(EndpointProvisioningStateCanceled), + string(EndpointProvisioningStateCreating), + string(EndpointProvisioningStateDeleting), + string(EndpointProvisioningStateFailed), + string(EndpointProvisioningStateSucceeded), + string(EndpointProvisioningStateUpdating), + } +} + +func (s *EndpointProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEndpointProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEndpointProvisioningState(input string) (*EndpointProvisioningState, error) { + vals := map[string]EndpointProvisioningState{ + "canceled": EndpointProvisioningStateCanceled, + "creating": EndpointProvisioningStateCreating, + "deleting": EndpointProvisioningStateDeleting, + "failed": EndpointProvisioningStateFailed, + "succeeded": EndpointProvisioningStateSucceeded, + "updating": EndpointProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EndpointProvisioningState(input) + return &out, nil +} + +type KeyType string + +const ( + KeyTypePrimary KeyType = "Primary" + KeyTypeSecondary KeyType = "Secondary" +) + +func PossibleValuesForKeyType() []string { + return []string{ + string(KeyTypePrimary), + string(KeyTypeSecondary), + } +} + +func (s *KeyType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseKeyType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseKeyType(input string) (*KeyType, error) { + vals := map[string]KeyType{ + "primary": KeyTypePrimary, + "secondary": KeyTypeSecondary, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := KeyType(input) + return &out, nil +} + +type ManagedServiceIdentityType string + +const ( + ManagedServiceIdentityTypeNone ManagedServiceIdentityType = "None" + ManagedServiceIdentityTypeSystemAssigned ManagedServiceIdentityType = "SystemAssigned" + ManagedServiceIdentityTypeSystemAssignedUserAssigned ManagedServiceIdentityType = "SystemAssigned,UserAssigned" + ManagedServiceIdentityTypeUserAssigned ManagedServiceIdentityType = "UserAssigned" +) + +func PossibleValuesForManagedServiceIdentityType() []string { + return []string{ + string(ManagedServiceIdentityTypeNone), + string(ManagedServiceIdentityTypeSystemAssigned), + string(ManagedServiceIdentityTypeSystemAssignedUserAssigned), + string(ManagedServiceIdentityTypeUserAssigned), + } +} + +func (s *ManagedServiceIdentityType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedServiceIdentityType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedServiceIdentityType(input string) (*ManagedServiceIdentityType, error) { + vals := map[string]ManagedServiceIdentityType{ + "none": ManagedServiceIdentityTypeNone, + "systemassigned": ManagedServiceIdentityTypeSystemAssigned, + "systemassigned,userassigned": ManagedServiceIdentityTypeSystemAssignedUserAssigned, + "userassigned": ManagedServiceIdentityTypeUserAssigned, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedServiceIdentityType(input) + return &out, nil +} + +type ServerlessEndpointState string + +const ( + ServerlessEndpointStateCreating ServerlessEndpointState = "Creating" + ServerlessEndpointStateCreationFailed ServerlessEndpointState = "CreationFailed" + ServerlessEndpointStateDeleting ServerlessEndpointState = "Deleting" + ServerlessEndpointStateDeletionFailed ServerlessEndpointState = "DeletionFailed" + ServerlessEndpointStateOnline ServerlessEndpointState = "Online" + ServerlessEndpointStateReinstating ServerlessEndpointState = "Reinstating" + ServerlessEndpointStateSuspended ServerlessEndpointState = "Suspended" + ServerlessEndpointStateSuspending ServerlessEndpointState = "Suspending" + ServerlessEndpointStateUnknown ServerlessEndpointState = "Unknown" +) + +func PossibleValuesForServerlessEndpointState() []string { + return []string{ + string(ServerlessEndpointStateCreating), + string(ServerlessEndpointStateCreationFailed), + string(ServerlessEndpointStateDeleting), + string(ServerlessEndpointStateDeletionFailed), + string(ServerlessEndpointStateOnline), + string(ServerlessEndpointStateReinstating), + string(ServerlessEndpointStateSuspended), + string(ServerlessEndpointStateSuspending), + string(ServerlessEndpointStateUnknown), + } +} + +func (s *ServerlessEndpointState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServerlessEndpointState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServerlessEndpointState(input string) (*ServerlessEndpointState, error) { + vals := map[string]ServerlessEndpointState{ + "creating": ServerlessEndpointStateCreating, + "creationfailed": ServerlessEndpointStateCreationFailed, + "deleting": ServerlessEndpointStateDeleting, + "deletionfailed": ServerlessEndpointStateDeletionFailed, + "online": ServerlessEndpointStateOnline, + "reinstating": ServerlessEndpointStateReinstating, + "suspended": ServerlessEndpointStateSuspended, + "suspending": ServerlessEndpointStateSuspending, + "unknown": ServerlessEndpointStateUnknown, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServerlessEndpointState(input) + return &out, nil +} + +type ServerlessInferenceEndpointAuthMode string + +const ( + ServerlessInferenceEndpointAuthModeKey ServerlessInferenceEndpointAuthMode = "Key" +) + +func PossibleValuesForServerlessInferenceEndpointAuthMode() []string { + return []string{ + string(ServerlessInferenceEndpointAuthModeKey), + } +} + +func (s *ServerlessInferenceEndpointAuthMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseServerlessInferenceEndpointAuthMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseServerlessInferenceEndpointAuthMode(input string) (*ServerlessInferenceEndpointAuthMode, error) { + vals := map[string]ServerlessInferenceEndpointAuthMode{ + "key": ServerlessInferenceEndpointAuthModeKey, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ServerlessInferenceEndpointAuthMode(input) + return &out, nil +} + +type SkuTier string + +const ( + SkuTierBasic SkuTier = "Basic" + SkuTierFree SkuTier = "Free" + SkuTierPremium SkuTier = "Premium" + SkuTierStandard SkuTier = "Standard" +) + +func PossibleValuesForSkuTier() []string { + return []string{ + string(SkuTierBasic), + string(SkuTierFree), + string(SkuTierPremium), + string(SkuTierStandard), + } +} + +func (s *SkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuTier(input string) (*SkuTier, error) { + vals := map[string]SkuTier{ + "basic": SkuTierBasic, + "free": SkuTierFree, + "premium": SkuTierPremium, + "standard": SkuTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuTier(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/id_serverlessendpoint.go b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/id_serverlessendpoint.go new file mode 100644 index 00000000000..4f875f4cddd --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/id_serverlessendpoint.go @@ -0,0 +1,139 @@ +package serverlessendpoint + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ServerlessEndpointId{}) +} + +var _ resourceids.ResourceId = &ServerlessEndpointId{} + +// ServerlessEndpointId is a struct representing the Resource ID for a Serverless Endpoint +type ServerlessEndpointId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + ServerlessEndpointName string +} + +// NewServerlessEndpointID returns a new ServerlessEndpointId struct +func NewServerlessEndpointID(subscriptionId string, resourceGroupName string, workspaceName string, serverlessEndpointName string) ServerlessEndpointId { + return ServerlessEndpointId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + ServerlessEndpointName: serverlessEndpointName, + } +} + +// ParseServerlessEndpointID parses 'input' into a ServerlessEndpointId +func ParseServerlessEndpointID(input string) (*ServerlessEndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServerlessEndpointId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServerlessEndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseServerlessEndpointIDInsensitively parses 'input' case-insensitively into a ServerlessEndpointId +// note: this method should only be used for API response data and not user input +func ParseServerlessEndpointIDInsensitively(input string) (*ServerlessEndpointId, error) { + parser := resourceids.NewParserFromResourceIdType(&ServerlessEndpointId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ServerlessEndpointId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ServerlessEndpointId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.ServerlessEndpointName, ok = input.Parsed["serverlessEndpointName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "serverlessEndpointName", input) + } + + return nil +} + +// ValidateServerlessEndpointID checks that 'input' can be parsed as a Serverless Endpoint ID +func ValidateServerlessEndpointID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseServerlessEndpointID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Serverless Endpoint ID +func (id ServerlessEndpointId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/serverlessEndpoints/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.ServerlessEndpointName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Serverless Endpoint ID +func (id ServerlessEndpointId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticServerlessEndpoints", "serverlessEndpoints", "serverlessEndpoints"), + resourceids.UserSpecifiedSegment("serverlessEndpointName", "serverlessEndpointName"), + } +} + +// String returns a human-readable description of this Serverless Endpoint ID +func (id ServerlessEndpointId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Serverless Endpoint Name: %q", id.ServerlessEndpointName), + } + return fmt.Sprintf("Serverless Endpoint (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/id_serverlessendpoint_test.go b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/id_serverlessendpoint_test.go new file mode 100644 index 00000000000..c1f4a1e2e52 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/id_serverlessendpoint_test.go @@ -0,0 +1,327 @@ +package serverlessendpoint + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ServerlessEndpointId{} + +func TestNewServerlessEndpointID(t *testing.T) { + id := NewServerlessEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "serverlessEndpointName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.ServerlessEndpointName != "serverlessEndpointName" { + t.Fatalf("Expected %q but got %q for Segment 'ServerlessEndpointName'", id.ServerlessEndpointName, "serverlessEndpointName") + } +} + +func TestFormatServerlessEndpointID(t *testing.T) { + actual := NewServerlessEndpointID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "serverlessEndpointName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/serverlessEndpoints/serverlessEndpointName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseServerlessEndpointID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServerlessEndpointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/serverlessEndpoints", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/serverlessEndpoints/serverlessEndpointName", + Expected: &ServerlessEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + ServerlessEndpointName: "serverlessEndpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/serverlessEndpoints/serverlessEndpointName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServerlessEndpointID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.ServerlessEndpointName != v.Expected.ServerlessEndpointName { + t.Fatalf("Expected %q but got %q for ServerlessEndpointName", v.Expected.ServerlessEndpointName, actual.ServerlessEndpointName) + } + + } +} + +func TestParseServerlessEndpointIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ServerlessEndpointId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/serverlessEndpoints", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/sErVeRlEsSeNdPoInTs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/serverlessEndpoints/serverlessEndpointName", + Expected: &ServerlessEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + ServerlessEndpointName: "serverlessEndpointName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/serverlessEndpoints/serverlessEndpointName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/sErVeRlEsSeNdPoInTs/sErVeRlEsSeNdPoInTnAmE", + Expected: &ServerlessEndpointId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + ServerlessEndpointName: "sErVeRlEsSeNdPoInTnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/sErVeRlEsSeNdPoInTs/sErVeRlEsSeNdPoInTnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseServerlessEndpointIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.ServerlessEndpointName != v.Expected.ServerlessEndpointName { + t.Fatalf("Expected %q but got %q for ServerlessEndpointName", v.Expected.ServerlessEndpointName, actual.ServerlessEndpointName) + } + + } +} + +func TestSegmentsForServerlessEndpointId(t *testing.T) { + segments := ServerlessEndpointId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ServerlessEndpointId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/id_workspace.go b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/id_workspace.go new file mode 100644 index 00000000000..a5595614a45 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/id_workspace.go @@ -0,0 +1,130 @@ +package serverlessendpoint + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/id_workspace_test.go b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/id_workspace_test.go new file mode 100644 index 00000000000..556908a797e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/id_workspace_test.go @@ -0,0 +1,282 @@ +package serverlessendpoint + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/method_createorupdate.go b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/method_createorupdate.go new file mode 100644 index 00000000000..2cd4bd2a2cc --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/method_createorupdate.go @@ -0,0 +1,75 @@ +package serverlessendpoint + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ServerlessEndpointTrackedResource +} + +// CreateOrUpdate ... +func (c ServerlessEndpointClient) CreateOrUpdate(ctx context.Context, id ServerlessEndpointId, input ServerlessEndpointTrackedResource) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusCreated, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c ServerlessEndpointClient) CreateOrUpdateThenPoll(ctx context.Context, id ServerlessEndpointId, input ServerlessEndpointTrackedResource) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/method_delete.go b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/method_delete.go new file mode 100644 index 00000000000..7f317c57d72 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/method_delete.go @@ -0,0 +1,70 @@ +package serverlessendpoint + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 ServerlessEndpointClient) Delete(ctx context.Context, id ServerlessEndpointId) (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 ServerlessEndpointClient) DeleteThenPoll(ctx context.Context, id ServerlessEndpointId) 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/machinelearningservices/2025-04-01/serverlessendpoint/method_get.go b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/method_get.go new file mode 100644 index 00000000000..cbfbe01eaa3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/method_get.go @@ -0,0 +1,53 @@ +package serverlessendpoint + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ServerlessEndpointTrackedResource +} + +// Get ... +func (c ServerlessEndpointClient) Get(ctx context.Context, id ServerlessEndpointId) (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 ServerlessEndpointTrackedResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/method_list.go b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/method_list.go new file mode 100644 index 00000000000..80fe546bd6e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/method_list.go @@ -0,0 +1,134 @@ +package serverlessendpoint + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]ServerlessEndpointTrackedResource +} + +type ListCompleteResult struct { + LatestHttpResponse *http.Response + Items []ServerlessEndpointTrackedResource +} + +type ListOperationOptions struct { + Skip *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.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + 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 ServerlessEndpointClient) List(ctx context.Context, id WorkspaceId, 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/serverlessEndpoints", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]ServerlessEndpointTrackedResource `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 ServerlessEndpointClient) ListComplete(ctx context.Context, id WorkspaceId, options ListOperationOptions) (ListCompleteResult, error) { + return c.ListCompleteMatchingPredicate(ctx, id, options, ServerlessEndpointTrackedResourceOperationPredicate{}) +} + +// ListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c ServerlessEndpointClient) ListCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, options ListOperationOptions, predicate ServerlessEndpointTrackedResourceOperationPredicate) (result ListCompleteResult, err error) { + items := make([]ServerlessEndpointTrackedResource, 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/machinelearningservices/2025-04-01/serverlessendpoint/method_listkeys.go b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/method_listkeys.go new file mode 100644 index 00000000000..5305675ec86 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/method_listkeys.go @@ -0,0 +1,54 @@ +package serverlessendpoint + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *EndpointAuthKeys +} + +// ListKeys ... +func (c ServerlessEndpointClient) ListKeys(ctx context.Context, id ServerlessEndpointId) (result ListKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model EndpointAuthKeys + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/method_regeneratekeys.go b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/method_regeneratekeys.go new file mode 100644 index 00000000000..2b8827d40e5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/method_regeneratekeys.go @@ -0,0 +1,75 @@ +package serverlessendpoint + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegenerateKeysOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *EndpointAuthKeys +} + +// RegenerateKeys ... +func (c ServerlessEndpointClient) RegenerateKeys(ctx context.Context, id ServerlessEndpointId, input RegenerateEndpointKeysRequest) (result RegenerateKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/regenerateKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// RegenerateKeysThenPoll performs RegenerateKeys then polls until it's completed +func (c ServerlessEndpointClient) RegenerateKeysThenPoll(ctx context.Context, id ServerlessEndpointId, input RegenerateEndpointKeysRequest) error { + result, err := c.RegenerateKeys(ctx, id, input) + if err != nil { + return fmt.Errorf("performing RegenerateKeys: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after RegenerateKeys: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/method_update.go b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/method_update.go new file mode 100644 index 00000000000..f2e6cf07bf5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/method_update.go @@ -0,0 +1,75 @@ +package serverlessendpoint + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *ServerlessEndpointTrackedResource +} + +// Update ... +func (c ServerlessEndpointClient) Update(ctx context.Context, id ServerlessEndpointId, input PartialMinimalTrackedResourceWithSkuAndIdentity) (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 ServerlessEndpointClient) UpdateThenPoll(ctx context.Context, id ServerlessEndpointId, input PartialMinimalTrackedResourceWithSkuAndIdentity) 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/machinelearningservices/2025-04-01/serverlessendpoint/model_contentsafety.go b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_contentsafety.go new file mode 100644 index 00000000000..95f2b913f19 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_contentsafety.go @@ -0,0 +1,8 @@ +package serverlessendpoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ContentSafety struct { + ContentSafetyStatus ContentSafetyStatus `json:"contentSafetyStatus"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_endpointauthkeys.go b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_endpointauthkeys.go new file mode 100644 index 00000000000..46e6316d51d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_endpointauthkeys.go @@ -0,0 +1,9 @@ +package serverlessendpoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EndpointAuthKeys struct { + PrimaryKey *string `json:"primaryKey,omitempty"` + SecondaryKey *string `json:"secondaryKey,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_modelsettings.go b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_modelsettings.go new file mode 100644 index 00000000000..4c4615216f6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_modelsettings.go @@ -0,0 +1,8 @@ +package serverlessendpoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ModelSettings struct { + ModelId *string `json:"modelId,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_partialmanagedserviceidentity.go b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_partialmanagedserviceidentity.go new file mode 100644 index 00000000000..179666f1ab0 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_partialmanagedserviceidentity.go @@ -0,0 +1,9 @@ +package serverlessendpoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PartialManagedServiceIdentity struct { + Type *ManagedServiceIdentityType `json:"type,omitempty"` + UserAssignedIdentities *map[string]interface{} `json:"userAssignedIdentities,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_partialminimaltrackedresourcewithskuandidentity.go b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_partialminimaltrackedresourcewithskuandidentity.go new file mode 100644 index 00000000000..0cdb09c9866 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_partialminimaltrackedresourcewithskuandidentity.go @@ -0,0 +1,10 @@ +package serverlessendpoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PartialMinimalTrackedResourceWithSkuAndIdentity struct { + Identity *PartialManagedServiceIdentity `json:"identity,omitempty"` + Sku *PartialSku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_partialsku.go b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_partialsku.go new file mode 100644 index 00000000000..fbf09a3435f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_partialsku.go @@ -0,0 +1,12 @@ +package serverlessendpoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PartialSku struct { + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Name *string `json:"name,omitempty"` + Size *string `json:"size,omitempty"` + Tier *SkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_regenerateendpointkeysrequest.go b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_regenerateendpointkeysrequest.go new file mode 100644 index 00000000000..0df7f3c95f4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_regenerateendpointkeysrequest.go @@ -0,0 +1,9 @@ +package serverlessendpoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegenerateEndpointKeysRequest struct { + KeyType KeyType `json:"keyType"` + KeyValue *string `json:"keyValue,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_serverlessendpoint.go b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_serverlessendpoint.go new file mode 100644 index 00000000000..3dd8c3e9c32 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_serverlessendpoint.go @@ -0,0 +1,14 @@ +package serverlessendpoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServerlessEndpoint struct { + AuthMode ServerlessInferenceEndpointAuthMode `json:"authMode"` + ContentSafety *ContentSafety `json:"contentSafety,omitempty"` + EndpointState *ServerlessEndpointState `json:"endpointState,omitempty"` + InferenceEndpoint *ServerlessInferenceEndpoint `json:"inferenceEndpoint,omitempty"` + MarketplaceSubscriptionId *string `json:"marketplaceSubscriptionId,omitempty"` + ModelSettings *ModelSettings `json:"modelSettings,omitempty"` + ProvisioningState *EndpointProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_serverlessendpointtrackedresource.go b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_serverlessendpointtrackedresource.go new file mode 100644 index 00000000000..5ae7dc82948 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_serverlessendpointtrackedresource.go @@ -0,0 +1,22 @@ +package serverlessendpoint + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServerlessEndpointTrackedResource struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Location string `json:"location"` + Name *string `json:"name,omitempty"` + Properties ServerlessEndpoint `json:"properties"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_serverlessinferenceendpoint.go b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_serverlessinferenceendpoint.go new file mode 100644 index 00000000000..cff44bc0352 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_serverlessinferenceendpoint.go @@ -0,0 +1,9 @@ +package serverlessendpoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServerlessInferenceEndpoint struct { + Headers *map[string]string `json:"headers,omitempty"` + Uri string `json:"uri"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_sku.go b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_sku.go new file mode 100644 index 00000000000..41eabf1e5a9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/model_sku.go @@ -0,0 +1,12 @@ +package serverlessendpoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Name string `json:"name"` + Size *string `json:"size,omitempty"` + Tier *SkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/predicates.go b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/predicates.go new file mode 100644 index 00000000000..328c37c17b8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/predicates.go @@ -0,0 +1,37 @@ +package serverlessendpoint + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServerlessEndpointTrackedResourceOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p ServerlessEndpointTrackedResourceOperationPredicate) Matches(input ServerlessEndpointTrackedResource) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && *p.Location != input.Location { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/version.go b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/version.go new file mode 100644 index 00000000000..aeeca752879 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/serverlessendpoint/version.go @@ -0,0 +1,10 @@ +package serverlessendpoint + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/serverlessendpoint/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/README.md b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/README.md new file mode 100644 index 00000000000..25ffdf01021 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/README.md @@ -0,0 +1,127 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource` Documentation + +The `v2workspaceconnectionresource` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource" +``` + + +### Client Initialization + +```go +client := v2workspaceconnectionresource.NewV2WorkspaceConnectionResourceClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `V2WorkspaceConnectionResourceClient.WorkspaceConnectionsCreate` + +```go +ctx := context.TODO() +id := v2workspaceconnectionresource.NewConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "connectionName") + +payload := v2workspaceconnectionresource.WorkspaceConnectionPropertiesV2BasicResource{ + // ... +} + + +read, err := client.WorkspaceConnectionsCreate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `V2WorkspaceConnectionResourceClient.WorkspaceConnectionsDelete` + +```go +ctx := context.TODO() +id := v2workspaceconnectionresource.NewConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "connectionName") + +read, err := client.WorkspaceConnectionsDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `V2WorkspaceConnectionResourceClient.WorkspaceConnectionsGet` + +```go +ctx := context.TODO() +id := v2workspaceconnectionresource.NewConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "connectionName") + +read, err := client.WorkspaceConnectionsGet(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `V2WorkspaceConnectionResourceClient.WorkspaceConnectionsList` + +```go +ctx := context.TODO() +id := v2workspaceconnectionresource.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +// alternatively `client.WorkspaceConnectionsList(ctx, id, v2workspaceconnectionresource.DefaultWorkspaceConnectionsListOperationOptions())` can be used to do batched pagination +items, err := client.WorkspaceConnectionsListComplete(ctx, id, v2workspaceconnectionresource.DefaultWorkspaceConnectionsListOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `V2WorkspaceConnectionResourceClient.WorkspaceConnectionsListSecrets` + +```go +ctx := context.TODO() +id := v2workspaceconnectionresource.NewConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "connectionName") + +read, err := client.WorkspaceConnectionsListSecrets(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `V2WorkspaceConnectionResourceClient.WorkspaceConnectionsUpdate` + +```go +ctx := context.TODO() +id := v2workspaceconnectionresource.NewConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "connectionName") + +payload := v2workspaceconnectionresource.WorkspaceConnectionUpdateParameter{ + // ... +} + + +read, err := client.WorkspaceConnectionsUpdate(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/machinelearningservices/2025-04-01/v2workspaceconnectionresource/client.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/client.go new file mode 100644 index 00000000000..0295936051a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/client.go @@ -0,0 +1,26 @@ +package v2workspaceconnectionresource + +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 V2WorkspaceConnectionResourceClient struct { + Client *resourcemanager.Client +} + +func NewV2WorkspaceConnectionResourceClientWithBaseURI(sdkApi sdkEnv.Api) (*V2WorkspaceConnectionResourceClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "v2workspaceconnectionresource", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating V2WorkspaceConnectionResourceClient: %+v", err) + } + + return &V2WorkspaceConnectionResourceClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/constants.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/constants.go new file mode 100644 index 00000000000..bb4ce8d9a95 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/constants.go @@ -0,0 +1,525 @@ +package v2workspaceconnectionresource + +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 ConnectionAuthType string + +const ( + ConnectionAuthTypeAAD ConnectionAuthType = "AAD" + ConnectionAuthTypeAccessKey ConnectionAuthType = "AccessKey" + ConnectionAuthTypeAccountKey ConnectionAuthType = "AccountKey" + ConnectionAuthTypeApiKey ConnectionAuthType = "ApiKey" + ConnectionAuthTypeCustomKeys ConnectionAuthType = "CustomKeys" + ConnectionAuthTypeManagedIdentity ConnectionAuthType = "ManagedIdentity" + ConnectionAuthTypeNone ConnectionAuthType = "None" + ConnectionAuthTypeOAuthTwo ConnectionAuthType = "OAuth2" + ConnectionAuthTypePAT ConnectionAuthType = "PAT" + ConnectionAuthTypeSAS ConnectionAuthType = "SAS" + ConnectionAuthTypeServicePrincipal ConnectionAuthType = "ServicePrincipal" + ConnectionAuthTypeUsernamePassword ConnectionAuthType = "UsernamePassword" +) + +func PossibleValuesForConnectionAuthType() []string { + return []string{ + string(ConnectionAuthTypeAAD), + string(ConnectionAuthTypeAccessKey), + string(ConnectionAuthTypeAccountKey), + string(ConnectionAuthTypeApiKey), + string(ConnectionAuthTypeCustomKeys), + string(ConnectionAuthTypeManagedIdentity), + string(ConnectionAuthTypeNone), + string(ConnectionAuthTypeOAuthTwo), + string(ConnectionAuthTypePAT), + string(ConnectionAuthTypeSAS), + string(ConnectionAuthTypeServicePrincipal), + string(ConnectionAuthTypeUsernamePassword), + } +} + +func (s *ConnectionAuthType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionAuthType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectionAuthType(input string) (*ConnectionAuthType, error) { + vals := map[string]ConnectionAuthType{ + "aad": ConnectionAuthTypeAAD, + "accesskey": ConnectionAuthTypeAccessKey, + "accountkey": ConnectionAuthTypeAccountKey, + "apikey": ConnectionAuthTypeApiKey, + "customkeys": ConnectionAuthTypeCustomKeys, + "managedidentity": ConnectionAuthTypeManagedIdentity, + "none": ConnectionAuthTypeNone, + "oauth2": ConnectionAuthTypeOAuthTwo, + "pat": ConnectionAuthTypePAT, + "sas": ConnectionAuthTypeSAS, + "serviceprincipal": ConnectionAuthTypeServicePrincipal, + "usernamepassword": ConnectionAuthTypeUsernamePassword, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectionAuthType(input) + return &out, nil +} + +type ConnectionCategory string + +const ( + ConnectionCategoryADLSGenTwo ConnectionCategory = "ADLSGen2" + ConnectionCategoryAIServices ConnectionCategory = "AIServices" + ConnectionCategoryAmazonMws ConnectionCategory = "AmazonMws" + ConnectionCategoryAmazonRdsForOracle ConnectionCategory = "AmazonRdsForOracle" + ConnectionCategoryAmazonRdsForSqlServer ConnectionCategory = "AmazonRdsForSqlServer" + ConnectionCategoryAmazonRedshift ConnectionCategory = "AmazonRedshift" + ConnectionCategoryAmazonSThreeCompatible ConnectionCategory = "AmazonS3Compatible" + ConnectionCategoryApiKey ConnectionCategory = "ApiKey" + ConnectionCategoryAzureBlob ConnectionCategory = "AzureBlob" + ConnectionCategoryAzureDataExplorer ConnectionCategory = "AzureDataExplorer" + ConnectionCategoryAzureDatabricksDeltaLake ConnectionCategory = "AzureDatabricksDeltaLake" + ConnectionCategoryAzureMariaDb ConnectionCategory = "AzureMariaDb" + ConnectionCategoryAzureMySqlDb ConnectionCategory = "AzureMySqlDb" + ConnectionCategoryAzureOneLake ConnectionCategory = "AzureOneLake" + ConnectionCategoryAzureOpenAI ConnectionCategory = "AzureOpenAI" + ConnectionCategoryAzurePostgresDb ConnectionCategory = "AzurePostgresDb" + ConnectionCategoryAzureSqlDb ConnectionCategory = "AzureSqlDb" + ConnectionCategoryAzureSqlMi ConnectionCategory = "AzureSqlMi" + ConnectionCategoryAzureSynapseAnalytics ConnectionCategory = "AzureSynapseAnalytics" + ConnectionCategoryAzureTableStorage ConnectionCategory = "AzureTableStorage" + ConnectionCategoryBingLLMSearch ConnectionCategory = "BingLLMSearch" + ConnectionCategoryCassandra ConnectionCategory = "Cassandra" + ConnectionCategoryCognitiveSearch ConnectionCategory = "CognitiveSearch" + ConnectionCategoryCognitiveService ConnectionCategory = "CognitiveService" + ConnectionCategoryConcur ConnectionCategory = "Concur" + ConnectionCategoryContainerRegistry ConnectionCategory = "ContainerRegistry" + ConnectionCategoryCosmosDb ConnectionCategory = "CosmosDb" + ConnectionCategoryCosmosDbMongoDbApi ConnectionCategory = "CosmosDbMongoDbApi" + ConnectionCategoryCouchbase ConnectionCategory = "Couchbase" + ConnectionCategoryCustomKeys ConnectionCategory = "CustomKeys" + ConnectionCategoryDbTwo ConnectionCategory = "Db2" + ConnectionCategoryDrill ConnectionCategory = "Drill" + ConnectionCategoryDynamics ConnectionCategory = "Dynamics" + ConnectionCategoryDynamicsAx ConnectionCategory = "DynamicsAx" + ConnectionCategoryDynamicsCrm ConnectionCategory = "DynamicsCrm" + ConnectionCategoryElasticsearch ConnectionCategory = "Elasticsearch" + ConnectionCategoryEloqua ConnectionCategory = "Eloqua" + ConnectionCategoryFileServer ConnectionCategory = "FileServer" + ConnectionCategoryFtpServer ConnectionCategory = "FtpServer" + ConnectionCategoryGenericContainerRegistry ConnectionCategory = "GenericContainerRegistry" + ConnectionCategoryGenericHTTP ConnectionCategory = "GenericHttp" + ConnectionCategoryGenericRest ConnectionCategory = "GenericRest" + ConnectionCategoryGit ConnectionCategory = "Git" + ConnectionCategoryGoogleAdWords ConnectionCategory = "GoogleAdWords" + ConnectionCategoryGoogleBigQuery ConnectionCategory = "GoogleBigQuery" + ConnectionCategoryGoogleCloudStorage ConnectionCategory = "GoogleCloudStorage" + ConnectionCategoryGreenplum ConnectionCategory = "Greenplum" + ConnectionCategoryHbase ConnectionCategory = "Hbase" + ConnectionCategoryHdfs ConnectionCategory = "Hdfs" + ConnectionCategoryHive ConnectionCategory = "Hive" + ConnectionCategoryHubspot ConnectionCategory = "Hubspot" + ConnectionCategoryImpala ConnectionCategory = "Impala" + ConnectionCategoryInformix ConnectionCategory = "Informix" + ConnectionCategoryJira ConnectionCategory = "Jira" + ConnectionCategoryMagento ConnectionCategory = "Magento" + ConnectionCategoryManagedOnlineEndpoint ConnectionCategory = "ManagedOnlineEndpoint" + ConnectionCategoryMariaDb ConnectionCategory = "MariaDb" + ConnectionCategoryMarketo ConnectionCategory = "Marketo" + ConnectionCategoryMicrosoftAccess ConnectionCategory = "MicrosoftAccess" + ConnectionCategoryMongoDbAtlas ConnectionCategory = "MongoDbAtlas" + ConnectionCategoryMongoDbVTwo ConnectionCategory = "MongoDbV2" + ConnectionCategoryMySql ConnectionCategory = "MySql" + ConnectionCategoryNetezza ConnectionCategory = "Netezza" + ConnectionCategoryODataRest ConnectionCategory = "ODataRest" + ConnectionCategoryOdbc ConnectionCategory = "Odbc" + ConnectionCategoryOfficeThreeSixFive ConnectionCategory = "Office365" + ConnectionCategoryOpenAI ConnectionCategory = "OpenAI" + ConnectionCategoryOracle ConnectionCategory = "Oracle" + ConnectionCategoryOracleCloudStorage ConnectionCategory = "OracleCloudStorage" + ConnectionCategoryOracleServiceCloud ConnectionCategory = "OracleServiceCloud" + ConnectionCategoryPayPal ConnectionCategory = "PayPal" + ConnectionCategoryPhoenix ConnectionCategory = "Phoenix" + ConnectionCategoryPinecone ConnectionCategory = "Pinecone" + ConnectionCategoryPostgreSql ConnectionCategory = "PostgreSql" + ConnectionCategoryPresto ConnectionCategory = "Presto" + ConnectionCategoryPythonFeed ConnectionCategory = "PythonFeed" + ConnectionCategoryQuickBooks ConnectionCategory = "QuickBooks" + ConnectionCategoryRedis ConnectionCategory = "Redis" + ConnectionCategoryResponsys ConnectionCategory = "Responsys" + ConnectionCategorySThree ConnectionCategory = "S3" + ConnectionCategorySalesforce ConnectionCategory = "Salesforce" + ConnectionCategorySalesforceMarketingCloud ConnectionCategory = "SalesforceMarketingCloud" + ConnectionCategorySalesforceServiceCloud ConnectionCategory = "SalesforceServiceCloud" + ConnectionCategorySapBw ConnectionCategory = "SapBw" + ConnectionCategorySapCloudForCustomer ConnectionCategory = "SapCloudForCustomer" + ConnectionCategorySapEcc ConnectionCategory = "SapEcc" + ConnectionCategorySapHana ConnectionCategory = "SapHana" + ConnectionCategorySapOpenHub ConnectionCategory = "SapOpenHub" + ConnectionCategorySapTable ConnectionCategory = "SapTable" + ConnectionCategorySerp ConnectionCategory = "Serp" + ConnectionCategoryServerless ConnectionCategory = "Serverless" + ConnectionCategoryServiceNow ConnectionCategory = "ServiceNow" + ConnectionCategorySftp ConnectionCategory = "Sftp" + ConnectionCategorySharePointOnlineList ConnectionCategory = "SharePointOnlineList" + ConnectionCategoryShopify ConnectionCategory = "Shopify" + ConnectionCategorySnowflake ConnectionCategory = "Snowflake" + ConnectionCategorySpark ConnectionCategory = "Spark" + ConnectionCategorySqlServer ConnectionCategory = "SqlServer" + ConnectionCategorySquare ConnectionCategory = "Square" + ConnectionCategorySybase ConnectionCategory = "Sybase" + ConnectionCategoryTeradata ConnectionCategory = "Teradata" + ConnectionCategoryVertica ConnectionCategory = "Vertica" + ConnectionCategoryWebTable ConnectionCategory = "WebTable" + ConnectionCategoryXero ConnectionCategory = "Xero" + ConnectionCategoryZoho ConnectionCategory = "Zoho" +) + +func PossibleValuesForConnectionCategory() []string { + return []string{ + string(ConnectionCategoryADLSGenTwo), + string(ConnectionCategoryAIServices), + string(ConnectionCategoryAmazonMws), + string(ConnectionCategoryAmazonRdsForOracle), + string(ConnectionCategoryAmazonRdsForSqlServer), + string(ConnectionCategoryAmazonRedshift), + string(ConnectionCategoryAmazonSThreeCompatible), + string(ConnectionCategoryApiKey), + string(ConnectionCategoryAzureBlob), + string(ConnectionCategoryAzureDataExplorer), + string(ConnectionCategoryAzureDatabricksDeltaLake), + string(ConnectionCategoryAzureMariaDb), + string(ConnectionCategoryAzureMySqlDb), + string(ConnectionCategoryAzureOneLake), + string(ConnectionCategoryAzureOpenAI), + string(ConnectionCategoryAzurePostgresDb), + string(ConnectionCategoryAzureSqlDb), + string(ConnectionCategoryAzureSqlMi), + string(ConnectionCategoryAzureSynapseAnalytics), + string(ConnectionCategoryAzureTableStorage), + string(ConnectionCategoryBingLLMSearch), + string(ConnectionCategoryCassandra), + string(ConnectionCategoryCognitiveSearch), + string(ConnectionCategoryCognitiveService), + string(ConnectionCategoryConcur), + string(ConnectionCategoryContainerRegistry), + string(ConnectionCategoryCosmosDb), + string(ConnectionCategoryCosmosDbMongoDbApi), + string(ConnectionCategoryCouchbase), + string(ConnectionCategoryCustomKeys), + string(ConnectionCategoryDbTwo), + string(ConnectionCategoryDrill), + string(ConnectionCategoryDynamics), + string(ConnectionCategoryDynamicsAx), + string(ConnectionCategoryDynamicsCrm), + string(ConnectionCategoryElasticsearch), + string(ConnectionCategoryEloqua), + string(ConnectionCategoryFileServer), + string(ConnectionCategoryFtpServer), + string(ConnectionCategoryGenericContainerRegistry), + string(ConnectionCategoryGenericHTTP), + string(ConnectionCategoryGenericRest), + string(ConnectionCategoryGit), + string(ConnectionCategoryGoogleAdWords), + string(ConnectionCategoryGoogleBigQuery), + string(ConnectionCategoryGoogleCloudStorage), + string(ConnectionCategoryGreenplum), + string(ConnectionCategoryHbase), + string(ConnectionCategoryHdfs), + string(ConnectionCategoryHive), + string(ConnectionCategoryHubspot), + string(ConnectionCategoryImpala), + string(ConnectionCategoryInformix), + string(ConnectionCategoryJira), + string(ConnectionCategoryMagento), + string(ConnectionCategoryManagedOnlineEndpoint), + string(ConnectionCategoryMariaDb), + string(ConnectionCategoryMarketo), + string(ConnectionCategoryMicrosoftAccess), + string(ConnectionCategoryMongoDbAtlas), + string(ConnectionCategoryMongoDbVTwo), + string(ConnectionCategoryMySql), + string(ConnectionCategoryNetezza), + string(ConnectionCategoryODataRest), + string(ConnectionCategoryOdbc), + string(ConnectionCategoryOfficeThreeSixFive), + string(ConnectionCategoryOpenAI), + string(ConnectionCategoryOracle), + string(ConnectionCategoryOracleCloudStorage), + string(ConnectionCategoryOracleServiceCloud), + string(ConnectionCategoryPayPal), + string(ConnectionCategoryPhoenix), + string(ConnectionCategoryPinecone), + string(ConnectionCategoryPostgreSql), + string(ConnectionCategoryPresto), + string(ConnectionCategoryPythonFeed), + string(ConnectionCategoryQuickBooks), + string(ConnectionCategoryRedis), + string(ConnectionCategoryResponsys), + string(ConnectionCategorySThree), + string(ConnectionCategorySalesforce), + string(ConnectionCategorySalesforceMarketingCloud), + string(ConnectionCategorySalesforceServiceCloud), + string(ConnectionCategorySapBw), + string(ConnectionCategorySapCloudForCustomer), + string(ConnectionCategorySapEcc), + string(ConnectionCategorySapHana), + string(ConnectionCategorySapOpenHub), + string(ConnectionCategorySapTable), + string(ConnectionCategorySerp), + string(ConnectionCategoryServerless), + string(ConnectionCategoryServiceNow), + string(ConnectionCategorySftp), + string(ConnectionCategorySharePointOnlineList), + string(ConnectionCategoryShopify), + string(ConnectionCategorySnowflake), + string(ConnectionCategorySpark), + string(ConnectionCategorySqlServer), + string(ConnectionCategorySquare), + string(ConnectionCategorySybase), + string(ConnectionCategoryTeradata), + string(ConnectionCategoryVertica), + string(ConnectionCategoryWebTable), + string(ConnectionCategoryXero), + string(ConnectionCategoryZoho), + } +} + +func (s *ConnectionCategory) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionCategory(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectionCategory(input string) (*ConnectionCategory, error) { + vals := map[string]ConnectionCategory{ + "adlsgen2": ConnectionCategoryADLSGenTwo, + "aiservices": ConnectionCategoryAIServices, + "amazonmws": ConnectionCategoryAmazonMws, + "amazonrdsfororacle": ConnectionCategoryAmazonRdsForOracle, + "amazonrdsforsqlserver": ConnectionCategoryAmazonRdsForSqlServer, + "amazonredshift": ConnectionCategoryAmazonRedshift, + "amazons3compatible": ConnectionCategoryAmazonSThreeCompatible, + "apikey": ConnectionCategoryApiKey, + "azureblob": ConnectionCategoryAzureBlob, + "azuredataexplorer": ConnectionCategoryAzureDataExplorer, + "azuredatabricksdeltalake": ConnectionCategoryAzureDatabricksDeltaLake, + "azuremariadb": ConnectionCategoryAzureMariaDb, + "azuremysqldb": ConnectionCategoryAzureMySqlDb, + "azureonelake": ConnectionCategoryAzureOneLake, + "azureopenai": ConnectionCategoryAzureOpenAI, + "azurepostgresdb": ConnectionCategoryAzurePostgresDb, + "azuresqldb": ConnectionCategoryAzureSqlDb, + "azuresqlmi": ConnectionCategoryAzureSqlMi, + "azuresynapseanalytics": ConnectionCategoryAzureSynapseAnalytics, + "azuretablestorage": ConnectionCategoryAzureTableStorage, + "bingllmsearch": ConnectionCategoryBingLLMSearch, + "cassandra": ConnectionCategoryCassandra, + "cognitivesearch": ConnectionCategoryCognitiveSearch, + "cognitiveservice": ConnectionCategoryCognitiveService, + "concur": ConnectionCategoryConcur, + "containerregistry": ConnectionCategoryContainerRegistry, + "cosmosdb": ConnectionCategoryCosmosDb, + "cosmosdbmongodbapi": ConnectionCategoryCosmosDbMongoDbApi, + "couchbase": ConnectionCategoryCouchbase, + "customkeys": ConnectionCategoryCustomKeys, + "db2": ConnectionCategoryDbTwo, + "drill": ConnectionCategoryDrill, + "dynamics": ConnectionCategoryDynamics, + "dynamicsax": ConnectionCategoryDynamicsAx, + "dynamicscrm": ConnectionCategoryDynamicsCrm, + "elasticsearch": ConnectionCategoryElasticsearch, + "eloqua": ConnectionCategoryEloqua, + "fileserver": ConnectionCategoryFileServer, + "ftpserver": ConnectionCategoryFtpServer, + "genericcontainerregistry": ConnectionCategoryGenericContainerRegistry, + "generichttp": ConnectionCategoryGenericHTTP, + "genericrest": ConnectionCategoryGenericRest, + "git": ConnectionCategoryGit, + "googleadwords": ConnectionCategoryGoogleAdWords, + "googlebigquery": ConnectionCategoryGoogleBigQuery, + "googlecloudstorage": ConnectionCategoryGoogleCloudStorage, + "greenplum": ConnectionCategoryGreenplum, + "hbase": ConnectionCategoryHbase, + "hdfs": ConnectionCategoryHdfs, + "hive": ConnectionCategoryHive, + "hubspot": ConnectionCategoryHubspot, + "impala": ConnectionCategoryImpala, + "informix": ConnectionCategoryInformix, + "jira": ConnectionCategoryJira, + "magento": ConnectionCategoryMagento, + "managedonlineendpoint": ConnectionCategoryManagedOnlineEndpoint, + "mariadb": ConnectionCategoryMariaDb, + "marketo": ConnectionCategoryMarketo, + "microsoftaccess": ConnectionCategoryMicrosoftAccess, + "mongodbatlas": ConnectionCategoryMongoDbAtlas, + "mongodbv2": ConnectionCategoryMongoDbVTwo, + "mysql": ConnectionCategoryMySql, + "netezza": ConnectionCategoryNetezza, + "odatarest": ConnectionCategoryODataRest, + "odbc": ConnectionCategoryOdbc, + "office365": ConnectionCategoryOfficeThreeSixFive, + "openai": ConnectionCategoryOpenAI, + "oracle": ConnectionCategoryOracle, + "oraclecloudstorage": ConnectionCategoryOracleCloudStorage, + "oracleservicecloud": ConnectionCategoryOracleServiceCloud, + "paypal": ConnectionCategoryPayPal, + "phoenix": ConnectionCategoryPhoenix, + "pinecone": ConnectionCategoryPinecone, + "postgresql": ConnectionCategoryPostgreSql, + "presto": ConnectionCategoryPresto, + "pythonfeed": ConnectionCategoryPythonFeed, + "quickbooks": ConnectionCategoryQuickBooks, + "redis": ConnectionCategoryRedis, + "responsys": ConnectionCategoryResponsys, + "s3": ConnectionCategorySThree, + "salesforce": ConnectionCategorySalesforce, + "salesforcemarketingcloud": ConnectionCategorySalesforceMarketingCloud, + "salesforceservicecloud": ConnectionCategorySalesforceServiceCloud, + "sapbw": ConnectionCategorySapBw, + "sapcloudforcustomer": ConnectionCategorySapCloudForCustomer, + "sapecc": ConnectionCategorySapEcc, + "saphana": ConnectionCategorySapHana, + "sapopenhub": ConnectionCategorySapOpenHub, + "saptable": ConnectionCategorySapTable, + "serp": ConnectionCategorySerp, + "serverless": ConnectionCategoryServerless, + "servicenow": ConnectionCategoryServiceNow, + "sftp": ConnectionCategorySftp, + "sharepointonlinelist": ConnectionCategorySharePointOnlineList, + "shopify": ConnectionCategoryShopify, + "snowflake": ConnectionCategorySnowflake, + "spark": ConnectionCategorySpark, + "sqlserver": ConnectionCategorySqlServer, + "square": ConnectionCategorySquare, + "sybase": ConnectionCategorySybase, + "teradata": ConnectionCategoryTeradata, + "vertica": ConnectionCategoryVertica, + "webtable": ConnectionCategoryWebTable, + "xero": ConnectionCategoryXero, + "zoho": ConnectionCategoryZoho, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectionCategory(input) + return &out, nil +} + +type ConnectionGroup string + +const ( + ConnectionGroupAzure ConnectionGroup = "Azure" + ConnectionGroupAzureAI ConnectionGroup = "AzureAI" + ConnectionGroupDatabase ConnectionGroup = "Database" + ConnectionGroupFile ConnectionGroup = "File" + ConnectionGroupGenericProtocol ConnectionGroup = "GenericProtocol" + ConnectionGroupNoSQL ConnectionGroup = "NoSQL" + ConnectionGroupServicesAndApps ConnectionGroup = "ServicesAndApps" +) + +func PossibleValuesForConnectionGroup() []string { + return []string{ + string(ConnectionGroupAzure), + string(ConnectionGroupAzureAI), + string(ConnectionGroupDatabase), + string(ConnectionGroupFile), + string(ConnectionGroupGenericProtocol), + string(ConnectionGroupNoSQL), + string(ConnectionGroupServicesAndApps), + } +} + +func (s *ConnectionGroup) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseConnectionGroup(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseConnectionGroup(input string) (*ConnectionGroup, error) { + vals := map[string]ConnectionGroup{ + "azure": ConnectionGroupAzure, + "azureai": ConnectionGroupAzureAI, + "database": ConnectionGroupDatabase, + "file": ConnectionGroupFile, + "genericprotocol": ConnectionGroupGenericProtocol, + "nosql": ConnectionGroupNoSQL, + "servicesandapps": ConnectionGroupServicesAndApps, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ConnectionGroup(input) + return &out, nil +} + +type ValueFormat string + +const ( + ValueFormatJSON ValueFormat = "JSON" +) + +func PossibleValuesForValueFormat() []string { + return []string{ + string(ValueFormatJSON), + } +} + +func (s *ValueFormat) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseValueFormat(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseValueFormat(input string) (*ValueFormat, error) { + vals := map[string]ValueFormat{ + "json": ValueFormatJSON, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ValueFormat(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/id_connection.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/id_connection.go new file mode 100644 index 00000000000..6907a912c4c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/id_connection.go @@ -0,0 +1,139 @@ +package v2workspaceconnectionresource + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&ConnectionId{}) +} + +var _ resourceids.ResourceId = &ConnectionId{} + +// ConnectionId is a struct representing the Resource ID for a Connection +type ConnectionId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string + ConnectionName string +} + +// NewConnectionID returns a new ConnectionId struct +func NewConnectionID(subscriptionId string, resourceGroupName string, workspaceName string, connectionName string) ConnectionId { + return ConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + ConnectionName: connectionName, + } +} + +// ParseConnectionID parses 'input' into a ConnectionId +func ParseConnectionID(input string) (*ConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectionId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseConnectionIDInsensitively parses 'input' case-insensitively into a ConnectionId +// note: this method should only be used for API response data and not user input +func ParseConnectionIDInsensitively(input string) (*ConnectionId, error) { + parser := resourceids.NewParserFromResourceIdType(&ConnectionId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := ConnectionId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *ConnectionId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + if id.ConnectionName, ok = input.Parsed["connectionName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "connectionName", input) + } + + return nil +} + +// ValidateConnectionID checks that 'input' can be parsed as a Connection ID +func ValidateConnectionID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseConnectionID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Connection ID +func (id ConnectionId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s/connections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, id.ConnectionName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Connection ID +func (id ConnectionId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + resourceids.StaticSegment("staticConnections", "connections", "connections"), + resourceids.UserSpecifiedSegment("connectionName", "connectionName"), + } +} + +// String returns a human-readable description of this Connection ID +func (id ConnectionId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + fmt.Sprintf("Connection Name: %q", id.ConnectionName), + } + return fmt.Sprintf("Connection (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/id_connection_test.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/id_connection_test.go new file mode 100644 index 00000000000..632c8215630 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/id_connection_test.go @@ -0,0 +1,327 @@ +package v2workspaceconnectionresource + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &ConnectionId{} + +func TestNewConnectionID(t *testing.T) { + id := NewConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "connectionName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + if id.ConnectionName != "connectionName" { + t.Fatalf("Expected %q but got %q for Segment 'ConnectionName'", id.ConnectionName, "connectionName") + } +} + +func TestFormatConnectionID(t *testing.T) { + actual := NewConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "connectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/connections/connectionName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseConnectionID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/connections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/connections/connectionName", + Expected: &ConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + ConnectionName: "connectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/connections/connectionName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectionID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.ConnectionName != v.Expected.ConnectionName { + t.Fatalf("Expected %q but got %q for ConnectionName", v.Expected.ConnectionName, actual.ConnectionName) + } + + } +} + +func TestParseConnectionIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *ConnectionId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/connections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOnNeCtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/connections/connectionName", + Expected: &ConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + ConnectionName: "connectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/connections/connectionName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOnNeCtIoNs/cOnNeCtIoNnAmE", + Expected: &ConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + ConnectionName: "cOnNeCtIoNnAmE", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/cOnNeCtIoNs/cOnNeCtIoNnAmE/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseConnectionIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + if actual.ConnectionName != v.Expected.ConnectionName { + t.Fatalf("Expected %q but got %q for ConnectionName", v.Expected.ConnectionName, actual.ConnectionName) + } + + } +} + +func TestSegmentsForConnectionId(t *testing.T) { + segments := ConnectionId{}.Segments() + if len(segments) == 0 { + t.Fatalf("ConnectionId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/id_workspace.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/id_workspace.go new file mode 100644 index 00000000000..cc20b0709ef --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/id_workspace.go @@ -0,0 +1,130 @@ +package v2workspaceconnectionresource + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/id_workspace_test.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/id_workspace_test.go new file mode 100644 index 00000000000..b484f48509d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/id_workspace_test.go @@ -0,0 +1,282 @@ +package v2workspaceconnectionresource + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/method_workspaceconnectionscreate.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/method_workspaceconnectionscreate.go new file mode 100644 index 00000000000..5441ad41b4b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/method_workspaceconnectionscreate.go @@ -0,0 +1,57 @@ +package v2workspaceconnectionresource + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceConnectionsCreateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkspaceConnectionPropertiesV2BasicResource +} + +// WorkspaceConnectionsCreate ... +func (c V2WorkspaceConnectionResourceClient) WorkspaceConnectionsCreate(ctx context.Context, id ConnectionId, input WorkspaceConnectionPropertiesV2BasicResource) (result WorkspaceConnectionsCreateOperationResponse, 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 WorkspaceConnectionPropertiesV2BasicResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/method_workspaceconnectionsdelete.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/method_workspaceconnectionsdelete.go new file mode 100644 index 00000000000..f4f744928df --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/method_workspaceconnectionsdelete.go @@ -0,0 +1,47 @@ +package v2workspaceconnectionresource + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceConnectionsDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// WorkspaceConnectionsDelete ... +func (c V2WorkspaceConnectionResourceClient) WorkspaceConnectionsDelete(ctx context.Context, id ConnectionId) (result WorkspaceConnectionsDeleteOperationResponse, 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/machinelearningservices/2025-04-01/v2workspaceconnectionresource/method_workspaceconnectionsget.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/method_workspaceconnectionsget.go new file mode 100644 index 00000000000..f7f1df9c9fb --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/method_workspaceconnectionsget.go @@ -0,0 +1,53 @@ +package v2workspaceconnectionresource + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceConnectionsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkspaceConnectionPropertiesV2BasicResource +} + +// WorkspaceConnectionsGet ... +func (c V2WorkspaceConnectionResourceClient) WorkspaceConnectionsGet(ctx context.Context, id ConnectionId) (result WorkspaceConnectionsGetOperationResponse, 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 WorkspaceConnectionPropertiesV2BasicResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/method_workspaceconnectionslist.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/method_workspaceconnectionslist.go new file mode 100644 index 00000000000..b8d139276cb --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/method_workspaceconnectionslist.go @@ -0,0 +1,142 @@ +package v2workspaceconnectionresource + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceConnectionsListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]WorkspaceConnectionPropertiesV2BasicResource +} + +type WorkspaceConnectionsListCompleteResult struct { + LatestHttpResponse *http.Response + Items []WorkspaceConnectionPropertiesV2BasicResource +} + +type WorkspaceConnectionsListOperationOptions struct { + Category *string + IncludeAll *bool + Target *string +} + +func DefaultWorkspaceConnectionsListOperationOptions() WorkspaceConnectionsListOperationOptions { + return WorkspaceConnectionsListOperationOptions{} +} + +func (o WorkspaceConnectionsListOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o WorkspaceConnectionsListOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o WorkspaceConnectionsListOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Category != nil { + out.Append("category", fmt.Sprintf("%v", *o.Category)) + } + if o.IncludeAll != nil { + out.Append("includeAll", fmt.Sprintf("%v", *o.IncludeAll)) + } + if o.Target != nil { + out.Append("target", fmt.Sprintf("%v", *o.Target)) + } + return &out +} + +type WorkspaceConnectionsListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *WorkspaceConnectionsListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// WorkspaceConnectionsList ... +func (c V2WorkspaceConnectionResourceClient) WorkspaceConnectionsList(ctx context.Context, id WorkspaceId, options WorkspaceConnectionsListOperationOptions) (result WorkspaceConnectionsListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &WorkspaceConnectionsListCustomPager{}, + Path: fmt.Sprintf("%s/connections", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]WorkspaceConnectionPropertiesV2BasicResource `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// WorkspaceConnectionsListComplete retrieves all the results into a single object +func (c V2WorkspaceConnectionResourceClient) WorkspaceConnectionsListComplete(ctx context.Context, id WorkspaceId, options WorkspaceConnectionsListOperationOptions) (WorkspaceConnectionsListCompleteResult, error) { + return c.WorkspaceConnectionsListCompleteMatchingPredicate(ctx, id, options, WorkspaceConnectionPropertiesV2BasicResourceOperationPredicate{}) +} + +// WorkspaceConnectionsListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c V2WorkspaceConnectionResourceClient) WorkspaceConnectionsListCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, options WorkspaceConnectionsListOperationOptions, predicate WorkspaceConnectionPropertiesV2BasicResourceOperationPredicate) (result WorkspaceConnectionsListCompleteResult, err error) { + items := make([]WorkspaceConnectionPropertiesV2BasicResource, 0) + + resp, err := c.WorkspaceConnectionsList(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 = WorkspaceConnectionsListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/method_workspaceconnectionslistsecrets.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/method_workspaceconnectionslistsecrets.go new file mode 100644 index 00000000000..5e15670b0b9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/method_workspaceconnectionslistsecrets.go @@ -0,0 +1,54 @@ +package v2workspaceconnectionresource + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceConnectionsListSecretsOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkspaceConnectionPropertiesV2BasicResource +} + +// WorkspaceConnectionsListSecrets ... +func (c V2WorkspaceConnectionResourceClient) WorkspaceConnectionsListSecrets(ctx context.Context, id ConnectionId) (result WorkspaceConnectionsListSecretsOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listsecrets", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model WorkspaceConnectionPropertiesV2BasicResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/method_workspaceconnectionsupdate.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/method_workspaceconnectionsupdate.go new file mode 100644 index 00000000000..8b8f030140e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/method_workspaceconnectionsupdate.go @@ -0,0 +1,57 @@ +package v2workspaceconnectionresource + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceConnectionsUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *WorkspaceConnectionPropertiesV2BasicResource +} + +// WorkspaceConnectionsUpdate ... +func (c V2WorkspaceConnectionResourceClient) WorkspaceConnectionsUpdate(ctx context.Context, id ConnectionId, input WorkspaceConnectionUpdateParameter) (result WorkspaceConnectionsUpdateOperationResponse, 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 WorkspaceConnectionPropertiesV2BasicResource + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_aadauthtypeworkspaceconnectionproperties.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_aadauthtypeworkspaceconnectionproperties.go new file mode 100644 index 00000000000..275a8eb73ae --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_aadauthtypeworkspaceconnectionproperties.go @@ -0,0 +1,84 @@ +package v2workspaceconnectionresource + +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. + +var _ WorkspaceConnectionPropertiesV2 = AADAuthTypeWorkspaceConnectionProperties{} + +type AADAuthTypeWorkspaceConnectionProperties struct { + + // Fields inherited from WorkspaceConnectionPropertiesV2 + + AuthType ConnectionAuthType `json:"authType"` + Category *ConnectionCategory `json:"category,omitempty"` + CreatedByWorkspaceArmId *string `json:"createdByWorkspaceArmId,omitempty"` + ExpiryTime *string `json:"expiryTime,omitempty"` + Group *ConnectionGroup `json:"group,omitempty"` + IsSharedToAll *bool `json:"isSharedToAll,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` + SharedUserList *[]string `json:"sharedUserList,omitempty"` + Target *string `json:"target,omitempty"` + Value *string `json:"value,omitempty"` + ValueFormat *ValueFormat `json:"valueFormat,omitempty"` +} + +func (s AADAuthTypeWorkspaceConnectionProperties) WorkspaceConnectionPropertiesV2() BaseWorkspaceConnectionPropertiesV2Impl { + return BaseWorkspaceConnectionPropertiesV2Impl{ + AuthType: s.AuthType, + Category: s.Category, + CreatedByWorkspaceArmId: s.CreatedByWorkspaceArmId, + ExpiryTime: s.ExpiryTime, + Group: s.Group, + IsSharedToAll: s.IsSharedToAll, + Metadata: s.Metadata, + SharedUserList: s.SharedUserList, + Target: s.Target, + Value: s.Value, + ValueFormat: s.ValueFormat, + } +} + +func (o *AADAuthTypeWorkspaceConnectionProperties) GetExpiryTimeAsTime() (*time.Time, error) { + if o.ExpiryTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpiryTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AADAuthTypeWorkspaceConnectionProperties) SetExpiryTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpiryTime = &formatted +} + +var _ json.Marshaler = AADAuthTypeWorkspaceConnectionProperties{} + +func (s AADAuthTypeWorkspaceConnectionProperties) MarshalJSON() ([]byte, error) { + type wrapper AADAuthTypeWorkspaceConnectionProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AADAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AADAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + decoded["authType"] = "AAD" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AADAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_accesskeyauthtypeworkspaceconnectionproperties.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_accesskeyauthtypeworkspaceconnectionproperties.go new file mode 100644 index 00000000000..99f3bd09761 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_accesskeyauthtypeworkspaceconnectionproperties.go @@ -0,0 +1,85 @@ +package v2workspaceconnectionresource + +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. + +var _ WorkspaceConnectionPropertiesV2 = AccessKeyAuthTypeWorkspaceConnectionProperties{} + +type AccessKeyAuthTypeWorkspaceConnectionProperties struct { + Credentials *WorkspaceConnectionAccessKey `json:"credentials,omitempty"` + + // Fields inherited from WorkspaceConnectionPropertiesV2 + + AuthType ConnectionAuthType `json:"authType"` + Category *ConnectionCategory `json:"category,omitempty"` + CreatedByWorkspaceArmId *string `json:"createdByWorkspaceArmId,omitempty"` + ExpiryTime *string `json:"expiryTime,omitempty"` + Group *ConnectionGroup `json:"group,omitempty"` + IsSharedToAll *bool `json:"isSharedToAll,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` + SharedUserList *[]string `json:"sharedUserList,omitempty"` + Target *string `json:"target,omitempty"` + Value *string `json:"value,omitempty"` + ValueFormat *ValueFormat `json:"valueFormat,omitempty"` +} + +func (s AccessKeyAuthTypeWorkspaceConnectionProperties) WorkspaceConnectionPropertiesV2() BaseWorkspaceConnectionPropertiesV2Impl { + return BaseWorkspaceConnectionPropertiesV2Impl{ + AuthType: s.AuthType, + Category: s.Category, + CreatedByWorkspaceArmId: s.CreatedByWorkspaceArmId, + ExpiryTime: s.ExpiryTime, + Group: s.Group, + IsSharedToAll: s.IsSharedToAll, + Metadata: s.Metadata, + SharedUserList: s.SharedUserList, + Target: s.Target, + Value: s.Value, + ValueFormat: s.ValueFormat, + } +} + +func (o *AccessKeyAuthTypeWorkspaceConnectionProperties) GetExpiryTimeAsTime() (*time.Time, error) { + if o.ExpiryTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpiryTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AccessKeyAuthTypeWorkspaceConnectionProperties) SetExpiryTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpiryTime = &formatted +} + +var _ json.Marshaler = AccessKeyAuthTypeWorkspaceConnectionProperties{} + +func (s AccessKeyAuthTypeWorkspaceConnectionProperties) MarshalJSON() ([]byte, error) { + type wrapper AccessKeyAuthTypeWorkspaceConnectionProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AccessKeyAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AccessKeyAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + decoded["authType"] = "AccessKey" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AccessKeyAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_accountkeyauthtypeworkspaceconnectionproperties.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_accountkeyauthtypeworkspaceconnectionproperties.go new file mode 100644 index 00000000000..f46bcb78187 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_accountkeyauthtypeworkspaceconnectionproperties.go @@ -0,0 +1,85 @@ +package v2workspaceconnectionresource + +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. + +var _ WorkspaceConnectionPropertiesV2 = AccountKeyAuthTypeWorkspaceConnectionProperties{} + +type AccountKeyAuthTypeWorkspaceConnectionProperties struct { + Credentials *WorkspaceConnectionAccountKey `json:"credentials,omitempty"` + + // Fields inherited from WorkspaceConnectionPropertiesV2 + + AuthType ConnectionAuthType `json:"authType"` + Category *ConnectionCategory `json:"category,omitempty"` + CreatedByWorkspaceArmId *string `json:"createdByWorkspaceArmId,omitempty"` + ExpiryTime *string `json:"expiryTime,omitempty"` + Group *ConnectionGroup `json:"group,omitempty"` + IsSharedToAll *bool `json:"isSharedToAll,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` + SharedUserList *[]string `json:"sharedUserList,omitempty"` + Target *string `json:"target,omitempty"` + Value *string `json:"value,omitempty"` + ValueFormat *ValueFormat `json:"valueFormat,omitempty"` +} + +func (s AccountKeyAuthTypeWorkspaceConnectionProperties) WorkspaceConnectionPropertiesV2() BaseWorkspaceConnectionPropertiesV2Impl { + return BaseWorkspaceConnectionPropertiesV2Impl{ + AuthType: s.AuthType, + Category: s.Category, + CreatedByWorkspaceArmId: s.CreatedByWorkspaceArmId, + ExpiryTime: s.ExpiryTime, + Group: s.Group, + IsSharedToAll: s.IsSharedToAll, + Metadata: s.Metadata, + SharedUserList: s.SharedUserList, + Target: s.Target, + Value: s.Value, + ValueFormat: s.ValueFormat, + } +} + +func (o *AccountKeyAuthTypeWorkspaceConnectionProperties) GetExpiryTimeAsTime() (*time.Time, error) { + if o.ExpiryTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpiryTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *AccountKeyAuthTypeWorkspaceConnectionProperties) SetExpiryTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpiryTime = &formatted +} + +var _ json.Marshaler = AccountKeyAuthTypeWorkspaceConnectionProperties{} + +func (s AccountKeyAuthTypeWorkspaceConnectionProperties) MarshalJSON() ([]byte, error) { + type wrapper AccountKeyAuthTypeWorkspaceConnectionProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling AccountKeyAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling AccountKeyAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + decoded["authType"] = "AccountKey" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling AccountKeyAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_apikeyauthworkspaceconnectionproperties.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_apikeyauthworkspaceconnectionproperties.go new file mode 100644 index 00000000000..77ea15f4197 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_apikeyauthworkspaceconnectionproperties.go @@ -0,0 +1,85 @@ +package v2workspaceconnectionresource + +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. + +var _ WorkspaceConnectionPropertiesV2 = ApiKeyAuthWorkspaceConnectionProperties{} + +type ApiKeyAuthWorkspaceConnectionProperties struct { + Credentials *WorkspaceConnectionApiKey `json:"credentials,omitempty"` + + // Fields inherited from WorkspaceConnectionPropertiesV2 + + AuthType ConnectionAuthType `json:"authType"` + Category *ConnectionCategory `json:"category,omitempty"` + CreatedByWorkspaceArmId *string `json:"createdByWorkspaceArmId,omitempty"` + ExpiryTime *string `json:"expiryTime,omitempty"` + Group *ConnectionGroup `json:"group,omitempty"` + IsSharedToAll *bool `json:"isSharedToAll,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` + SharedUserList *[]string `json:"sharedUserList,omitempty"` + Target *string `json:"target,omitempty"` + Value *string `json:"value,omitempty"` + ValueFormat *ValueFormat `json:"valueFormat,omitempty"` +} + +func (s ApiKeyAuthWorkspaceConnectionProperties) WorkspaceConnectionPropertiesV2() BaseWorkspaceConnectionPropertiesV2Impl { + return BaseWorkspaceConnectionPropertiesV2Impl{ + AuthType: s.AuthType, + Category: s.Category, + CreatedByWorkspaceArmId: s.CreatedByWorkspaceArmId, + ExpiryTime: s.ExpiryTime, + Group: s.Group, + IsSharedToAll: s.IsSharedToAll, + Metadata: s.Metadata, + SharedUserList: s.SharedUserList, + Target: s.Target, + Value: s.Value, + ValueFormat: s.ValueFormat, + } +} + +func (o *ApiKeyAuthWorkspaceConnectionProperties) GetExpiryTimeAsTime() (*time.Time, error) { + if o.ExpiryTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpiryTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ApiKeyAuthWorkspaceConnectionProperties) SetExpiryTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpiryTime = &formatted +} + +var _ json.Marshaler = ApiKeyAuthWorkspaceConnectionProperties{} + +func (s ApiKeyAuthWorkspaceConnectionProperties) MarshalJSON() ([]byte, error) { + type wrapper ApiKeyAuthWorkspaceConnectionProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ApiKeyAuthWorkspaceConnectionProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ApiKeyAuthWorkspaceConnectionProperties: %+v", err) + } + + decoded["authType"] = "ApiKey" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ApiKeyAuthWorkspaceConnectionProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_customkeys.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_customkeys.go new file mode 100644 index 00000000000..54d7cae8d86 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_customkeys.go @@ -0,0 +1,8 @@ +package v2workspaceconnectionresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CustomKeys struct { + Keys *map[string]string `json:"keys,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_customkeysworkspaceconnectionproperties.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_customkeysworkspaceconnectionproperties.go new file mode 100644 index 00000000000..9478e790770 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_customkeysworkspaceconnectionproperties.go @@ -0,0 +1,85 @@ +package v2workspaceconnectionresource + +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. + +var _ WorkspaceConnectionPropertiesV2 = CustomKeysWorkspaceConnectionProperties{} + +type CustomKeysWorkspaceConnectionProperties struct { + Credentials *CustomKeys `json:"credentials,omitempty"` + + // Fields inherited from WorkspaceConnectionPropertiesV2 + + AuthType ConnectionAuthType `json:"authType"` + Category *ConnectionCategory `json:"category,omitempty"` + CreatedByWorkspaceArmId *string `json:"createdByWorkspaceArmId,omitempty"` + ExpiryTime *string `json:"expiryTime,omitempty"` + Group *ConnectionGroup `json:"group,omitempty"` + IsSharedToAll *bool `json:"isSharedToAll,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` + SharedUserList *[]string `json:"sharedUserList,omitempty"` + Target *string `json:"target,omitempty"` + Value *string `json:"value,omitempty"` + ValueFormat *ValueFormat `json:"valueFormat,omitempty"` +} + +func (s CustomKeysWorkspaceConnectionProperties) WorkspaceConnectionPropertiesV2() BaseWorkspaceConnectionPropertiesV2Impl { + return BaseWorkspaceConnectionPropertiesV2Impl{ + AuthType: s.AuthType, + Category: s.Category, + CreatedByWorkspaceArmId: s.CreatedByWorkspaceArmId, + ExpiryTime: s.ExpiryTime, + Group: s.Group, + IsSharedToAll: s.IsSharedToAll, + Metadata: s.Metadata, + SharedUserList: s.SharedUserList, + Target: s.Target, + Value: s.Value, + ValueFormat: s.ValueFormat, + } +} + +func (o *CustomKeysWorkspaceConnectionProperties) GetExpiryTimeAsTime() (*time.Time, error) { + if o.ExpiryTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpiryTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *CustomKeysWorkspaceConnectionProperties) SetExpiryTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpiryTime = &formatted +} + +var _ json.Marshaler = CustomKeysWorkspaceConnectionProperties{} + +func (s CustomKeysWorkspaceConnectionProperties) MarshalJSON() ([]byte, error) { + type wrapper CustomKeysWorkspaceConnectionProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling CustomKeysWorkspaceConnectionProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling CustomKeysWorkspaceConnectionProperties: %+v", err) + } + + decoded["authType"] = "CustomKeys" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling CustomKeysWorkspaceConnectionProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_managedidentityauthtypeworkspaceconnectionproperties.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_managedidentityauthtypeworkspaceconnectionproperties.go new file mode 100644 index 00000000000..dd807bedcb5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_managedidentityauthtypeworkspaceconnectionproperties.go @@ -0,0 +1,85 @@ +package v2workspaceconnectionresource + +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. + +var _ WorkspaceConnectionPropertiesV2 = ManagedIdentityAuthTypeWorkspaceConnectionProperties{} + +type ManagedIdentityAuthTypeWorkspaceConnectionProperties struct { + Credentials *WorkspaceConnectionManagedIdentity `json:"credentials,omitempty"` + + // Fields inherited from WorkspaceConnectionPropertiesV2 + + AuthType ConnectionAuthType `json:"authType"` + Category *ConnectionCategory `json:"category,omitempty"` + CreatedByWorkspaceArmId *string `json:"createdByWorkspaceArmId,omitempty"` + ExpiryTime *string `json:"expiryTime,omitempty"` + Group *ConnectionGroup `json:"group,omitempty"` + IsSharedToAll *bool `json:"isSharedToAll,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` + SharedUserList *[]string `json:"sharedUserList,omitempty"` + Target *string `json:"target,omitempty"` + Value *string `json:"value,omitempty"` + ValueFormat *ValueFormat `json:"valueFormat,omitempty"` +} + +func (s ManagedIdentityAuthTypeWorkspaceConnectionProperties) WorkspaceConnectionPropertiesV2() BaseWorkspaceConnectionPropertiesV2Impl { + return BaseWorkspaceConnectionPropertiesV2Impl{ + AuthType: s.AuthType, + Category: s.Category, + CreatedByWorkspaceArmId: s.CreatedByWorkspaceArmId, + ExpiryTime: s.ExpiryTime, + Group: s.Group, + IsSharedToAll: s.IsSharedToAll, + Metadata: s.Metadata, + SharedUserList: s.SharedUserList, + Target: s.Target, + Value: s.Value, + ValueFormat: s.ValueFormat, + } +} + +func (o *ManagedIdentityAuthTypeWorkspaceConnectionProperties) GetExpiryTimeAsTime() (*time.Time, error) { + if o.ExpiryTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpiryTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ManagedIdentityAuthTypeWorkspaceConnectionProperties) SetExpiryTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpiryTime = &formatted +} + +var _ json.Marshaler = ManagedIdentityAuthTypeWorkspaceConnectionProperties{} + +func (s ManagedIdentityAuthTypeWorkspaceConnectionProperties) MarshalJSON() ([]byte, error) { + type wrapper ManagedIdentityAuthTypeWorkspaceConnectionProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ManagedIdentityAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ManagedIdentityAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + decoded["authType"] = "ManagedIdentity" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ManagedIdentityAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_noneauthtypeworkspaceconnectionproperties.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_noneauthtypeworkspaceconnectionproperties.go new file mode 100644 index 00000000000..a7021260298 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_noneauthtypeworkspaceconnectionproperties.go @@ -0,0 +1,84 @@ +package v2workspaceconnectionresource + +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. + +var _ WorkspaceConnectionPropertiesV2 = NoneAuthTypeWorkspaceConnectionProperties{} + +type NoneAuthTypeWorkspaceConnectionProperties struct { + + // Fields inherited from WorkspaceConnectionPropertiesV2 + + AuthType ConnectionAuthType `json:"authType"` + Category *ConnectionCategory `json:"category,omitempty"` + CreatedByWorkspaceArmId *string `json:"createdByWorkspaceArmId,omitempty"` + ExpiryTime *string `json:"expiryTime,omitempty"` + Group *ConnectionGroup `json:"group,omitempty"` + IsSharedToAll *bool `json:"isSharedToAll,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` + SharedUserList *[]string `json:"sharedUserList,omitempty"` + Target *string `json:"target,omitempty"` + Value *string `json:"value,omitempty"` + ValueFormat *ValueFormat `json:"valueFormat,omitempty"` +} + +func (s NoneAuthTypeWorkspaceConnectionProperties) WorkspaceConnectionPropertiesV2() BaseWorkspaceConnectionPropertiesV2Impl { + return BaseWorkspaceConnectionPropertiesV2Impl{ + AuthType: s.AuthType, + Category: s.Category, + CreatedByWorkspaceArmId: s.CreatedByWorkspaceArmId, + ExpiryTime: s.ExpiryTime, + Group: s.Group, + IsSharedToAll: s.IsSharedToAll, + Metadata: s.Metadata, + SharedUserList: s.SharedUserList, + Target: s.Target, + Value: s.Value, + ValueFormat: s.ValueFormat, + } +} + +func (o *NoneAuthTypeWorkspaceConnectionProperties) GetExpiryTimeAsTime() (*time.Time, error) { + if o.ExpiryTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpiryTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *NoneAuthTypeWorkspaceConnectionProperties) SetExpiryTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpiryTime = &formatted +} + +var _ json.Marshaler = NoneAuthTypeWorkspaceConnectionProperties{} + +func (s NoneAuthTypeWorkspaceConnectionProperties) MarshalJSON() ([]byte, error) { + type wrapper NoneAuthTypeWorkspaceConnectionProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling NoneAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling NoneAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + decoded["authType"] = "None" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling NoneAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_oauth2authtypeworkspaceconnectionproperties.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_oauth2authtypeworkspaceconnectionproperties.go new file mode 100644 index 00000000000..0e5bd86d733 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_oauth2authtypeworkspaceconnectionproperties.go @@ -0,0 +1,85 @@ +package v2workspaceconnectionresource + +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. + +var _ WorkspaceConnectionPropertiesV2 = OAuth2AuthTypeWorkspaceConnectionProperties{} + +type OAuth2AuthTypeWorkspaceConnectionProperties struct { + Credentials *WorkspaceConnectionOAuth2 `json:"credentials,omitempty"` + + // Fields inherited from WorkspaceConnectionPropertiesV2 + + AuthType ConnectionAuthType `json:"authType"` + Category *ConnectionCategory `json:"category,omitempty"` + CreatedByWorkspaceArmId *string `json:"createdByWorkspaceArmId,omitempty"` + ExpiryTime *string `json:"expiryTime,omitempty"` + Group *ConnectionGroup `json:"group,omitempty"` + IsSharedToAll *bool `json:"isSharedToAll,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` + SharedUserList *[]string `json:"sharedUserList,omitempty"` + Target *string `json:"target,omitempty"` + Value *string `json:"value,omitempty"` + ValueFormat *ValueFormat `json:"valueFormat,omitempty"` +} + +func (s OAuth2AuthTypeWorkspaceConnectionProperties) WorkspaceConnectionPropertiesV2() BaseWorkspaceConnectionPropertiesV2Impl { + return BaseWorkspaceConnectionPropertiesV2Impl{ + AuthType: s.AuthType, + Category: s.Category, + CreatedByWorkspaceArmId: s.CreatedByWorkspaceArmId, + ExpiryTime: s.ExpiryTime, + Group: s.Group, + IsSharedToAll: s.IsSharedToAll, + Metadata: s.Metadata, + SharedUserList: s.SharedUserList, + Target: s.Target, + Value: s.Value, + ValueFormat: s.ValueFormat, + } +} + +func (o *OAuth2AuthTypeWorkspaceConnectionProperties) GetExpiryTimeAsTime() (*time.Time, error) { + if o.ExpiryTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpiryTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *OAuth2AuthTypeWorkspaceConnectionProperties) SetExpiryTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpiryTime = &formatted +} + +var _ json.Marshaler = OAuth2AuthTypeWorkspaceConnectionProperties{} + +func (s OAuth2AuthTypeWorkspaceConnectionProperties) MarshalJSON() ([]byte, error) { + type wrapper OAuth2AuthTypeWorkspaceConnectionProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling OAuth2AuthTypeWorkspaceConnectionProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling OAuth2AuthTypeWorkspaceConnectionProperties: %+v", err) + } + + decoded["authType"] = "OAuth2" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling OAuth2AuthTypeWorkspaceConnectionProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_patauthtypeworkspaceconnectionproperties.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_patauthtypeworkspaceconnectionproperties.go new file mode 100644 index 00000000000..5bc9b19c7c7 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_patauthtypeworkspaceconnectionproperties.go @@ -0,0 +1,85 @@ +package v2workspaceconnectionresource + +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. + +var _ WorkspaceConnectionPropertiesV2 = PATAuthTypeWorkspaceConnectionProperties{} + +type PATAuthTypeWorkspaceConnectionProperties struct { + Credentials *WorkspaceConnectionPersonalAccessToken `json:"credentials,omitempty"` + + // Fields inherited from WorkspaceConnectionPropertiesV2 + + AuthType ConnectionAuthType `json:"authType"` + Category *ConnectionCategory `json:"category,omitempty"` + CreatedByWorkspaceArmId *string `json:"createdByWorkspaceArmId,omitempty"` + ExpiryTime *string `json:"expiryTime,omitempty"` + Group *ConnectionGroup `json:"group,omitempty"` + IsSharedToAll *bool `json:"isSharedToAll,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` + SharedUserList *[]string `json:"sharedUserList,omitempty"` + Target *string `json:"target,omitempty"` + Value *string `json:"value,omitempty"` + ValueFormat *ValueFormat `json:"valueFormat,omitempty"` +} + +func (s PATAuthTypeWorkspaceConnectionProperties) WorkspaceConnectionPropertiesV2() BaseWorkspaceConnectionPropertiesV2Impl { + return BaseWorkspaceConnectionPropertiesV2Impl{ + AuthType: s.AuthType, + Category: s.Category, + CreatedByWorkspaceArmId: s.CreatedByWorkspaceArmId, + ExpiryTime: s.ExpiryTime, + Group: s.Group, + IsSharedToAll: s.IsSharedToAll, + Metadata: s.Metadata, + SharedUserList: s.SharedUserList, + Target: s.Target, + Value: s.Value, + ValueFormat: s.ValueFormat, + } +} + +func (o *PATAuthTypeWorkspaceConnectionProperties) GetExpiryTimeAsTime() (*time.Time, error) { + if o.ExpiryTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpiryTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *PATAuthTypeWorkspaceConnectionProperties) SetExpiryTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpiryTime = &formatted +} + +var _ json.Marshaler = PATAuthTypeWorkspaceConnectionProperties{} + +func (s PATAuthTypeWorkspaceConnectionProperties) MarshalJSON() ([]byte, error) { + type wrapper PATAuthTypeWorkspaceConnectionProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling PATAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling PATAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + decoded["authType"] = "PAT" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling PATAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_sasauthtypeworkspaceconnectionproperties.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_sasauthtypeworkspaceconnectionproperties.go new file mode 100644 index 00000000000..356bc4467e2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_sasauthtypeworkspaceconnectionproperties.go @@ -0,0 +1,85 @@ +package v2workspaceconnectionresource + +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. + +var _ WorkspaceConnectionPropertiesV2 = SASAuthTypeWorkspaceConnectionProperties{} + +type SASAuthTypeWorkspaceConnectionProperties struct { + Credentials *WorkspaceConnectionSharedAccessSignature `json:"credentials,omitempty"` + + // Fields inherited from WorkspaceConnectionPropertiesV2 + + AuthType ConnectionAuthType `json:"authType"` + Category *ConnectionCategory `json:"category,omitempty"` + CreatedByWorkspaceArmId *string `json:"createdByWorkspaceArmId,omitempty"` + ExpiryTime *string `json:"expiryTime,omitempty"` + Group *ConnectionGroup `json:"group,omitempty"` + IsSharedToAll *bool `json:"isSharedToAll,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` + SharedUserList *[]string `json:"sharedUserList,omitempty"` + Target *string `json:"target,omitempty"` + Value *string `json:"value,omitempty"` + ValueFormat *ValueFormat `json:"valueFormat,omitempty"` +} + +func (s SASAuthTypeWorkspaceConnectionProperties) WorkspaceConnectionPropertiesV2() BaseWorkspaceConnectionPropertiesV2Impl { + return BaseWorkspaceConnectionPropertiesV2Impl{ + AuthType: s.AuthType, + Category: s.Category, + CreatedByWorkspaceArmId: s.CreatedByWorkspaceArmId, + ExpiryTime: s.ExpiryTime, + Group: s.Group, + IsSharedToAll: s.IsSharedToAll, + Metadata: s.Metadata, + SharedUserList: s.SharedUserList, + Target: s.Target, + Value: s.Value, + ValueFormat: s.ValueFormat, + } +} + +func (o *SASAuthTypeWorkspaceConnectionProperties) GetExpiryTimeAsTime() (*time.Time, error) { + if o.ExpiryTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpiryTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *SASAuthTypeWorkspaceConnectionProperties) SetExpiryTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpiryTime = &formatted +} + +var _ json.Marshaler = SASAuthTypeWorkspaceConnectionProperties{} + +func (s SASAuthTypeWorkspaceConnectionProperties) MarshalJSON() ([]byte, error) { + type wrapper SASAuthTypeWorkspaceConnectionProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling SASAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling SASAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + decoded["authType"] = "SAS" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling SASAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_serviceprincipalauthtypeworkspaceconnectionproperties.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_serviceprincipalauthtypeworkspaceconnectionproperties.go new file mode 100644 index 00000000000..02d616a82d6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_serviceprincipalauthtypeworkspaceconnectionproperties.go @@ -0,0 +1,85 @@ +package v2workspaceconnectionresource + +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. + +var _ WorkspaceConnectionPropertiesV2 = ServicePrincipalAuthTypeWorkspaceConnectionProperties{} + +type ServicePrincipalAuthTypeWorkspaceConnectionProperties struct { + Credentials *WorkspaceConnectionServicePrincipal `json:"credentials,omitempty"` + + // Fields inherited from WorkspaceConnectionPropertiesV2 + + AuthType ConnectionAuthType `json:"authType"` + Category *ConnectionCategory `json:"category,omitempty"` + CreatedByWorkspaceArmId *string `json:"createdByWorkspaceArmId,omitempty"` + ExpiryTime *string `json:"expiryTime,omitempty"` + Group *ConnectionGroup `json:"group,omitempty"` + IsSharedToAll *bool `json:"isSharedToAll,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` + SharedUserList *[]string `json:"sharedUserList,omitempty"` + Target *string `json:"target,omitempty"` + Value *string `json:"value,omitempty"` + ValueFormat *ValueFormat `json:"valueFormat,omitempty"` +} + +func (s ServicePrincipalAuthTypeWorkspaceConnectionProperties) WorkspaceConnectionPropertiesV2() BaseWorkspaceConnectionPropertiesV2Impl { + return BaseWorkspaceConnectionPropertiesV2Impl{ + AuthType: s.AuthType, + Category: s.Category, + CreatedByWorkspaceArmId: s.CreatedByWorkspaceArmId, + ExpiryTime: s.ExpiryTime, + Group: s.Group, + IsSharedToAll: s.IsSharedToAll, + Metadata: s.Metadata, + SharedUserList: s.SharedUserList, + Target: s.Target, + Value: s.Value, + ValueFormat: s.ValueFormat, + } +} + +func (o *ServicePrincipalAuthTypeWorkspaceConnectionProperties) GetExpiryTimeAsTime() (*time.Time, error) { + if o.ExpiryTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpiryTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *ServicePrincipalAuthTypeWorkspaceConnectionProperties) SetExpiryTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpiryTime = &formatted +} + +var _ json.Marshaler = ServicePrincipalAuthTypeWorkspaceConnectionProperties{} + +func (s ServicePrincipalAuthTypeWorkspaceConnectionProperties) MarshalJSON() ([]byte, error) { + type wrapper ServicePrincipalAuthTypeWorkspaceConnectionProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ServicePrincipalAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ServicePrincipalAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + decoded["authType"] = "ServicePrincipal" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ServicePrincipalAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_usernamepasswordauthtypeworkspaceconnectionproperties.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_usernamepasswordauthtypeworkspaceconnectionproperties.go new file mode 100644 index 00000000000..86cb683ab19 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_usernamepasswordauthtypeworkspaceconnectionproperties.go @@ -0,0 +1,85 @@ +package v2workspaceconnectionresource + +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. + +var _ WorkspaceConnectionPropertiesV2 = UsernamePasswordAuthTypeWorkspaceConnectionProperties{} + +type UsernamePasswordAuthTypeWorkspaceConnectionProperties struct { + Credentials *WorkspaceConnectionUsernamePassword `json:"credentials,omitempty"` + + // Fields inherited from WorkspaceConnectionPropertiesV2 + + AuthType ConnectionAuthType `json:"authType"` + Category *ConnectionCategory `json:"category,omitempty"` + CreatedByWorkspaceArmId *string `json:"createdByWorkspaceArmId,omitempty"` + ExpiryTime *string `json:"expiryTime,omitempty"` + Group *ConnectionGroup `json:"group,omitempty"` + IsSharedToAll *bool `json:"isSharedToAll,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` + SharedUserList *[]string `json:"sharedUserList,omitempty"` + Target *string `json:"target,omitempty"` + Value *string `json:"value,omitempty"` + ValueFormat *ValueFormat `json:"valueFormat,omitempty"` +} + +func (s UsernamePasswordAuthTypeWorkspaceConnectionProperties) WorkspaceConnectionPropertiesV2() BaseWorkspaceConnectionPropertiesV2Impl { + return BaseWorkspaceConnectionPropertiesV2Impl{ + AuthType: s.AuthType, + Category: s.Category, + CreatedByWorkspaceArmId: s.CreatedByWorkspaceArmId, + ExpiryTime: s.ExpiryTime, + Group: s.Group, + IsSharedToAll: s.IsSharedToAll, + Metadata: s.Metadata, + SharedUserList: s.SharedUserList, + Target: s.Target, + Value: s.Value, + ValueFormat: s.ValueFormat, + } +} + +func (o *UsernamePasswordAuthTypeWorkspaceConnectionProperties) GetExpiryTimeAsTime() (*time.Time, error) { + if o.ExpiryTime == nil { + return nil, nil + } + return dates.ParseAsFormat(o.ExpiryTime, "2006-01-02T15:04:05Z07:00") +} + +func (o *UsernamePasswordAuthTypeWorkspaceConnectionProperties) SetExpiryTimeAsTime(input time.Time) { + formatted := input.Format("2006-01-02T15:04:05Z07:00") + o.ExpiryTime = &formatted +} + +var _ json.Marshaler = UsernamePasswordAuthTypeWorkspaceConnectionProperties{} + +func (s UsernamePasswordAuthTypeWorkspaceConnectionProperties) MarshalJSON() ([]byte, error) { + type wrapper UsernamePasswordAuthTypeWorkspaceConnectionProperties + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling UsernamePasswordAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling UsernamePasswordAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + decoded["authType"] = "UsernamePassword" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling UsernamePasswordAuthTypeWorkspaceConnectionProperties: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionaccesskey.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionaccesskey.go new file mode 100644 index 00000000000..3c82ecf123f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionaccesskey.go @@ -0,0 +1,9 @@ +package v2workspaceconnectionresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceConnectionAccessKey struct { + AccessKeyId *string `json:"accessKeyId,omitempty"` + SecretAccessKey *string `json:"secretAccessKey,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionaccountkey.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionaccountkey.go new file mode 100644 index 00000000000..dba2e8dfd8e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionaccountkey.go @@ -0,0 +1,8 @@ +package v2workspaceconnectionresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceConnectionAccountKey struct { + Key *string `json:"key,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionapikey.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionapikey.go new file mode 100644 index 00000000000..1f7dd5060ba --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionapikey.go @@ -0,0 +1,8 @@ +package v2workspaceconnectionresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceConnectionApiKey struct { + Key *string `json:"key,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionmanagedidentity.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionmanagedidentity.go new file mode 100644 index 00000000000..de1608d4212 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionmanagedidentity.go @@ -0,0 +1,9 @@ +package v2workspaceconnectionresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceConnectionManagedIdentity struct { + ClientId *string `json:"clientId,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionoauth2.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionoauth2.go new file mode 100644 index 00000000000..91542858e88 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionoauth2.go @@ -0,0 +1,15 @@ +package v2workspaceconnectionresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceConnectionOAuth2 struct { + AuthURL *string `json:"authUrl,omitempty"` + ClientId *string `json:"clientId,omitempty"` + ClientSecret *string `json:"clientSecret,omitempty"` + DeveloperToken *string `json:"developerToken,omitempty"` + Password *string `json:"password,omitempty"` + RefreshToken *string `json:"refreshToken,omitempty"` + TenantId *string `json:"tenantId,omitempty"` + Username *string `json:"username,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionpersonalaccesstoken.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionpersonalaccesstoken.go new file mode 100644 index 00000000000..e532db804ca --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionpersonalaccesstoken.go @@ -0,0 +1,8 @@ +package v2workspaceconnectionresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceConnectionPersonalAccessToken struct { + Pat *string `json:"pat,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionpropertiesv2.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionpropertiesv2.go new file mode 100644 index 00000000000..6922383b8a0 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionpropertiesv2.go @@ -0,0 +1,173 @@ +package v2workspaceconnectionresource + +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 WorkspaceConnectionPropertiesV2 interface { + WorkspaceConnectionPropertiesV2() BaseWorkspaceConnectionPropertiesV2Impl +} + +var _ WorkspaceConnectionPropertiesV2 = BaseWorkspaceConnectionPropertiesV2Impl{} + +type BaseWorkspaceConnectionPropertiesV2Impl struct { + AuthType ConnectionAuthType `json:"authType"` + Category *ConnectionCategory `json:"category,omitempty"` + CreatedByWorkspaceArmId *string `json:"createdByWorkspaceArmId,omitempty"` + ExpiryTime *string `json:"expiryTime,omitempty"` + Group *ConnectionGroup `json:"group,omitempty"` + IsSharedToAll *bool `json:"isSharedToAll,omitempty"` + Metadata *map[string]string `json:"metadata,omitempty"` + SharedUserList *[]string `json:"sharedUserList,omitempty"` + Target *string `json:"target,omitempty"` + Value *string `json:"value,omitempty"` + ValueFormat *ValueFormat `json:"valueFormat,omitempty"` +} + +func (s BaseWorkspaceConnectionPropertiesV2Impl) WorkspaceConnectionPropertiesV2() BaseWorkspaceConnectionPropertiesV2Impl { + return s +} + +var _ WorkspaceConnectionPropertiesV2 = RawWorkspaceConnectionPropertiesV2Impl{} + +// RawWorkspaceConnectionPropertiesV2Impl 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 RawWorkspaceConnectionPropertiesV2Impl struct { + workspaceConnectionPropertiesV2 BaseWorkspaceConnectionPropertiesV2Impl + Type string + Values map[string]interface{} +} + +func (s RawWorkspaceConnectionPropertiesV2Impl) WorkspaceConnectionPropertiesV2() BaseWorkspaceConnectionPropertiesV2Impl { + return s.workspaceConnectionPropertiesV2 +} + +func UnmarshalWorkspaceConnectionPropertiesV2Implementation(input []byte) (WorkspaceConnectionPropertiesV2, 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 WorkspaceConnectionPropertiesV2 into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["authType"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "AAD") { + var out AADAuthTypeWorkspaceConnectionProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AADAuthTypeWorkspaceConnectionProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AccessKey") { + var out AccessKeyAuthTypeWorkspaceConnectionProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AccessKeyAuthTypeWorkspaceConnectionProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "AccountKey") { + var out AccountKeyAuthTypeWorkspaceConnectionProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into AccountKeyAuthTypeWorkspaceConnectionProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ApiKey") { + var out ApiKeyAuthWorkspaceConnectionProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ApiKeyAuthWorkspaceConnectionProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "CustomKeys") { + var out CustomKeysWorkspaceConnectionProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into CustomKeysWorkspaceConnectionProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ManagedIdentity") { + var out ManagedIdentityAuthTypeWorkspaceConnectionProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ManagedIdentityAuthTypeWorkspaceConnectionProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "None") { + var out NoneAuthTypeWorkspaceConnectionProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into NoneAuthTypeWorkspaceConnectionProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "OAuth2") { + var out OAuth2AuthTypeWorkspaceConnectionProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into OAuth2AuthTypeWorkspaceConnectionProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "PAT") { + var out PATAuthTypeWorkspaceConnectionProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into PATAuthTypeWorkspaceConnectionProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "SAS") { + var out SASAuthTypeWorkspaceConnectionProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into SASAuthTypeWorkspaceConnectionProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ServicePrincipal") { + var out ServicePrincipalAuthTypeWorkspaceConnectionProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ServicePrincipalAuthTypeWorkspaceConnectionProperties: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "UsernamePassword") { + var out UsernamePasswordAuthTypeWorkspaceConnectionProperties + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into UsernamePasswordAuthTypeWorkspaceConnectionProperties: %+v", err) + } + return out, nil + } + + var parent BaseWorkspaceConnectionPropertiesV2Impl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseWorkspaceConnectionPropertiesV2Impl: %+v", err) + } + + return RawWorkspaceConnectionPropertiesV2Impl{ + workspaceConnectionPropertiesV2: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionpropertiesv2basicresource.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionpropertiesv2basicresource.go new file mode 100644 index 00000000000..04a99c8bfb6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionpropertiesv2basicresource.go @@ -0,0 +1,53 @@ +package v2workspaceconnectionresource + +import ( + "encoding/json" + "fmt" + + "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 WorkspaceConnectionPropertiesV2BasicResource struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + Properties WorkspaceConnectionPropertiesV2 `json:"properties"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` +} + +var _ json.Unmarshaler = &WorkspaceConnectionPropertiesV2BasicResource{} + +func (s *WorkspaceConnectionPropertiesV2BasicResource) UnmarshalJSON(bytes []byte) error { + var decoded struct { + Id *string `json:"id,omitempty"` + Name *string `json:"name,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Type *string `json:"type,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.Id = decoded.Id + s.Name = decoded.Name + s.SystemData = decoded.SystemData + s.Type = decoded.Type + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling WorkspaceConnectionPropertiesV2BasicResource into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalWorkspaceConnectionPropertiesV2Implementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'WorkspaceConnectionPropertiesV2BasicResource': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionserviceprincipal.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionserviceprincipal.go new file mode 100644 index 00000000000..2bc976df1ec --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionserviceprincipal.go @@ -0,0 +1,10 @@ +package v2workspaceconnectionresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceConnectionServicePrincipal struct { + ClientId *string `json:"clientId,omitempty"` + ClientSecret *string `json:"clientSecret,omitempty"` + TenantId *string `json:"tenantId,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionsharedaccesssignature.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionsharedaccesssignature.go new file mode 100644 index 00000000000..7e4f10bd434 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionsharedaccesssignature.go @@ -0,0 +1,8 @@ +package v2workspaceconnectionresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceConnectionSharedAccessSignature struct { + Sas *string `json:"sas,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionupdateparameter.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionupdateparameter.go new file mode 100644 index 00000000000..14a4320a115 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionupdateparameter.go @@ -0,0 +1,33 @@ +package v2workspaceconnectionresource + +import ( + "encoding/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 WorkspaceConnectionUpdateParameter struct { + Properties WorkspaceConnectionPropertiesV2 `json:"properties"` +} + +var _ json.Unmarshaler = &WorkspaceConnectionUpdateParameter{} + +func (s *WorkspaceConnectionUpdateParameter) UnmarshalJSON(bytes []byte) error { + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling WorkspaceConnectionUpdateParameter into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["properties"]; ok { + impl, err := UnmarshalWorkspaceConnectionPropertiesV2Implementation(v) + if err != nil { + return fmt.Errorf("unmarshaling field 'Properties' for 'WorkspaceConnectionUpdateParameter': %+v", err) + } + s.Properties = impl + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionusernamepassword.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionusernamepassword.go new file mode 100644 index 00000000000..34c5ce64956 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/model_workspaceconnectionusernamepassword.go @@ -0,0 +1,10 @@ +package v2workspaceconnectionresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceConnectionUsernamePassword struct { + Password *string `json:"password,omitempty"` + SecurityToken *string `json:"securityToken,omitempty"` + Username *string `json:"username,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/predicates.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/predicates.go new file mode 100644 index 00000000000..1fa8bf9ad9f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/predicates.go @@ -0,0 +1,27 @@ +package v2workspaceconnectionresource + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceConnectionPropertiesV2BasicResourceOperationPredicate struct { + Id *string + Name *string + Type *string +} + +func (p WorkspaceConnectionPropertiesV2BasicResourceOperationPredicate) Matches(input WorkspaceConnectionPropertiesV2BasicResource) 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/machinelearningservices/2025-04-01/v2workspaceconnectionresource/version.go b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/version.go new file mode 100644 index 00000000000..c47abdc9b09 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/v2workspaceconnectionresource/version.go @@ -0,0 +1,10 @@ +package v2workspaceconnectionresource + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/v2workspaceconnectionresource/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/README.md b/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/README.md new file mode 100644 index 00000000000..9f970ec1868 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes` Documentation + +The `virtualmachinesizes` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes" +``` + + +### Client Initialization + +```go +client := virtualmachinesizes.NewVirtualMachineSizesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `VirtualMachineSizesClient.List` + +```go +ctx := context.TODO() +id := virtualmachinesizes.NewLocationID("12345678-1234-9876-4563-123456789012", "locationName") + +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/machinelearningservices/2025-04-01/virtualmachinesizes/client.go b/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/client.go new file mode 100644 index 00000000000..cce54e682d2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/client.go @@ -0,0 +1,26 @@ +package virtualmachinesizes + +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 VirtualMachineSizesClient struct { + Client *resourcemanager.Client +} + +func NewVirtualMachineSizesClientWithBaseURI(sdkApi sdkEnv.Api) (*VirtualMachineSizesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "virtualmachinesizes", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating VirtualMachineSizesClient: %+v", err) + } + + return &VirtualMachineSizesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/constants.go b/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/constants.go new file mode 100644 index 00000000000..23fb0268602 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/constants.go @@ -0,0 +1,171 @@ +package virtualmachinesizes + +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 BillingCurrency string + +const ( + BillingCurrencyUSD BillingCurrency = "USD" +) + +func PossibleValuesForBillingCurrency() []string { + return []string{ + string(BillingCurrencyUSD), + } +} + +func (s *BillingCurrency) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseBillingCurrency(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseBillingCurrency(input string) (*BillingCurrency, error) { + vals := map[string]BillingCurrency{ + "usd": BillingCurrencyUSD, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := BillingCurrency(input) + return &out, nil +} + +type UnitOfMeasure string + +const ( + UnitOfMeasureOneHour UnitOfMeasure = "OneHour" +) + +func PossibleValuesForUnitOfMeasure() []string { + return []string{ + string(UnitOfMeasureOneHour), + } +} + +func (s *UnitOfMeasure) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseUnitOfMeasure(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseUnitOfMeasure(input string) (*UnitOfMeasure, error) { + vals := map[string]UnitOfMeasure{ + "onehour": UnitOfMeasureOneHour, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := UnitOfMeasure(input) + return &out, nil +} + +type VMPriceOSType string + +const ( + VMPriceOSTypeLinux VMPriceOSType = "Linux" + VMPriceOSTypeWindows VMPriceOSType = "Windows" +) + +func PossibleValuesForVMPriceOSType() []string { + return []string{ + string(VMPriceOSTypeLinux), + string(VMPriceOSTypeWindows), + } +} + +func (s *VMPriceOSType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVMPriceOSType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVMPriceOSType(input string) (*VMPriceOSType, error) { + vals := map[string]VMPriceOSType{ + "linux": VMPriceOSTypeLinux, + "windows": VMPriceOSTypeWindows, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VMPriceOSType(input) + return &out, nil +} + +type VMTier string + +const ( + VMTierLowPriority VMTier = "LowPriority" + VMTierSpot VMTier = "Spot" + VMTierStandard VMTier = "Standard" +) + +func PossibleValuesForVMTier() []string { + return []string{ + string(VMTierLowPriority), + string(VMTierSpot), + string(VMTierStandard), + } +} + +func (s *VMTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseVMTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseVMTier(input string) (*VMTier, error) { + vals := map[string]VMTier{ + "lowpriority": VMTierLowPriority, + "spot": VMTierSpot, + "standard": VMTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := VMTier(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/id_location.go b/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/id_location.go new file mode 100644 index 00000000000..b556359201a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/id_location.go @@ -0,0 +1,121 @@ +package virtualmachinesizes + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) 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.MachineLearningServices/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("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + 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/machinelearningservices/2025-04-01/virtualmachinesizes/id_location_test.go b/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/id_location_test.go new file mode 100644 index 00000000000..1a82ed39871 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/id_location_test.go @@ -0,0 +1,237 @@ +package virtualmachinesizes + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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.MachineLearningServices/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.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MachineLearningServices/locations", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MachineLearningServices/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.MachineLearningServices/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.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MachineLearningServices/locations", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/lOcAtIoNs", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/providers/Microsoft.MachineLearningServices/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.MachineLearningServices/locations/locationName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/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.mAcHiNeLeArNiNgSeRvIcEs/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/machinelearningservices/2025-04-01/virtualmachinesizes/method_list.go b/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/method_list.go new file mode 100644 index 00000000000..15d02b46c23 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/method_list.go @@ -0,0 +1,54 @@ +package virtualmachinesizes + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *VirtualMachineSizeListResult +} + +// List ... +func (c VirtualMachineSizesClient) List(ctx context.Context, id LocationId) (result ListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Path: fmt.Sprintf("%s/vmSizes", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model VirtualMachineSizeListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/model_estimatedvmprice.go b/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/model_estimatedvmprice.go new file mode 100644 index 00000000000..499e27eaee6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/model_estimatedvmprice.go @@ -0,0 +1,10 @@ +package virtualmachinesizes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EstimatedVMPrice struct { + OsType VMPriceOSType `json:"osType"` + RetailPrice float64 `json:"retailPrice"` + VMTier VMTier `json:"vmTier"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/model_estimatedvmprices.go b/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/model_estimatedvmprices.go new file mode 100644 index 00000000000..ff8ca98872d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/model_estimatedvmprices.go @@ -0,0 +1,10 @@ +package virtualmachinesizes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EstimatedVMPrices struct { + BillingCurrency BillingCurrency `json:"billingCurrency"` + UnitOfMeasure UnitOfMeasure `json:"unitOfMeasure"` + Values []EstimatedVMPrice `json:"values"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/model_virtualmachinesize.go b/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/model_virtualmachinesize.go new file mode 100644 index 00000000000..1125186be63 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/model_virtualmachinesize.go @@ -0,0 +1,18 @@ +package virtualmachinesizes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineSize struct { + EstimatedVMPrices *EstimatedVMPrices `json:"estimatedVMPrices,omitempty"` + Family *string `json:"family,omitempty"` + Gpus *int64 `json:"gpus,omitempty"` + LowPriorityCapable *bool `json:"lowPriorityCapable,omitempty"` + MaxResourceVolumeMB *int64 `json:"maxResourceVolumeMB,omitempty"` + MemoryGB *float64 `json:"memoryGB,omitempty"` + Name *string `json:"name,omitempty"` + OsVhdSizeMB *int64 `json:"osVhdSizeMB,omitempty"` + PremiumIO *bool `json:"premiumIO,omitempty"` + SupportedComputeTypes *[]string `json:"supportedComputeTypes,omitempty"` + VCPUs *int64 `json:"vCPUs,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/model_virtualmachinesizelistresult.go b/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/model_virtualmachinesizelistresult.go new file mode 100644 index 00000000000..86db7ace1a7 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/model_virtualmachinesizelistresult.go @@ -0,0 +1,8 @@ +package virtualmachinesizes + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type VirtualMachineSizeListResult struct { + Value *[]VirtualMachineSize `json:"value,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/version.go b/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/version.go new file mode 100644 index 00000000000..855f687958c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/virtualmachinesizes/version.go @@ -0,0 +1,10 @@ +package virtualmachinesizes + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/virtualmachinesizes/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/README.md b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/README.md new file mode 100644 index 00000000000..a3f7c3e3dec --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/README.md @@ -0,0 +1,73 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections` Documentation + +The `workspaceprivateendpointconnections` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections" +``` + + +### Client Initialization + +```go +client := workspaceprivateendpointconnections.NewWorkspacePrivateEndpointConnectionsClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WorkspacePrivateEndpointConnectionsClient.PrivateEndpointConnectionsCreateOrUpdate` + +```go +ctx := context.TODO() +id := workspaceprivateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "privateEndpointConnectionName") + +payload := workspaceprivateendpointconnections.PrivateEndpointConnection{ + // ... +} + + +read, err := client.PrivateEndpointConnectionsCreateOrUpdate(ctx, id, payload) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkspacePrivateEndpointConnectionsClient.PrivateEndpointConnectionsDelete` + +```go +ctx := context.TODO() +id := workspaceprivateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "privateEndpointConnectionName") + +read, err := client.PrivateEndpointConnectionsDelete(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkspacePrivateEndpointConnectionsClient.PrivateEndpointConnectionsGet` + +```go +ctx := context.TODO() +id := workspaceprivateendpointconnections.NewPrivateEndpointConnectionID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "privateEndpointConnectionName") + +read, err := client.PrivateEndpointConnectionsGet(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/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/client.go b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/client.go new file mode 100644 index 00000000000..7f6dad6c63b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/client.go @@ -0,0 +1,26 @@ +package workspaceprivateendpointconnections + +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 WorkspacePrivateEndpointConnectionsClient struct { + Client *resourcemanager.Client +} + +func NewWorkspacePrivateEndpointConnectionsClientWithBaseURI(sdkApi sdkEnv.Api) (*WorkspacePrivateEndpointConnectionsClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "workspaceprivateendpointconnections", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkspacePrivateEndpointConnectionsClient: %+v", err) + } + + return &WorkspacePrivateEndpointConnectionsClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/constants.go b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/constants.go new file mode 100644 index 00000000000..c3cad39e6b6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/constants.go @@ -0,0 +1,154 @@ +package workspaceprivateendpointconnections + +import ( + "encoding/json" + "fmt" + "strings" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + } +} + +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusDisconnected PrivateEndpointServiceConnectionStatus = "Disconnected" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" + PrivateEndpointServiceConnectionStatusTimeout PrivateEndpointServiceConnectionStatus = "Timeout" +) + +func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { + return []string{ + string(PrivateEndpointServiceConnectionStatusApproved), + string(PrivateEndpointServiceConnectionStatusDisconnected), + string(PrivateEndpointServiceConnectionStatusPending), + string(PrivateEndpointServiceConnectionStatusRejected), + string(PrivateEndpointServiceConnectionStatusTimeout), + } +} + +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { + vals := map[string]PrivateEndpointServiceConnectionStatus{ + "approved": PrivateEndpointServiceConnectionStatusApproved, + "disconnected": PrivateEndpointServiceConnectionStatusDisconnected, + "pending": PrivateEndpointServiceConnectionStatusPending, + "rejected": PrivateEndpointServiceConnectionStatusRejected, + "timeout": PrivateEndpointServiceConnectionStatusTimeout, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointServiceConnectionStatus(input) + return &out, nil +} + +type SkuTier string + +const ( + SkuTierBasic SkuTier = "Basic" + SkuTierFree SkuTier = "Free" + SkuTierPremium SkuTier = "Premium" + SkuTierStandard SkuTier = "Standard" +) + +func PossibleValuesForSkuTier() []string { + return []string{ + string(SkuTierBasic), + string(SkuTierFree), + string(SkuTierPremium), + string(SkuTierStandard), + } +} + +func (s *SkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuTier(input string) (*SkuTier, error) { + vals := map[string]SkuTier{ + "basic": SkuTierBasic, + "free": SkuTierFree, + "premium": SkuTierPremium, + "standard": SkuTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuTier(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/id_privateendpointconnection.go b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/id_privateendpointconnection.go new file mode 100644 index 00000000000..6181af6b8db --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/id_privateendpointconnection.go @@ -0,0 +1,139 @@ +package workspaceprivateendpointconnections + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) 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 + WorkspaceName string + PrivateEndpointConnectionName string +} + +// NewPrivateEndpointConnectionID returns a new PrivateEndpointConnectionId struct +func NewPrivateEndpointConnectionID(subscriptionId string, resourceGroupName string, workspaceName string, privateEndpointConnectionName string) PrivateEndpointConnectionId { + return PrivateEndpointConnectionId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + 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.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", 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.MachineLearningServices/workspaces/%s/privateEndpointConnections/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName, 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("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + 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("Workspace Name: %q", id.WorkspaceName), + 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/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/id_privateendpointconnection_test.go b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/id_privateendpointconnection_test.go new file mode 100644 index 00000000000..1663b85c010 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/id_privateendpointconnection_test.go @@ -0,0 +1,327 @@ +package workspaceprivateendpointconnections + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (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", "workspaceName", "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.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } + + 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", "workspaceName", "privateEndpointConnectionName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/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.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/privateEndpointConnections", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + 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.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/privateEndpointConnections", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/privateEndpointConnections/privateEndpointConnectionName", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + PrivateEndpointConnectionName: "privateEndpointConnectionName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/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.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/pRiVaTeEnDpOiNtCoNnEcTiOnS/pRiVaTeEnDpOiNtCoNnEcTiOnNaMe", + Expected: &PrivateEndpointConnectionId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + 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.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/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.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + 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/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/method_privateendpointconnectionscreateorupdate.go b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/method_privateendpointconnectionscreateorupdate.go new file mode 100644 index 00000000000..875cb76a479 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/method_privateendpointconnectionscreateorupdate.go @@ -0,0 +1,57 @@ +package workspaceprivateendpointconnections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionsCreateOrUpdateOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// PrivateEndpointConnectionsCreateOrUpdate ... +func (c WorkspacePrivateEndpointConnectionsClient) PrivateEndpointConnectionsCreateOrUpdate(ctx context.Context, id PrivateEndpointConnectionId, input PrivateEndpointConnection) (result PrivateEndpointConnectionsCreateOrUpdateOperationResponse, 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 PrivateEndpointConnection + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/method_privateendpointconnectionsdelete.go b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/method_privateendpointconnectionsdelete.go new file mode 100644 index 00000000000..f747c6b3579 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/method_privateendpointconnectionsdelete.go @@ -0,0 +1,47 @@ +package workspaceprivateendpointconnections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionsDeleteOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData +} + +// PrivateEndpointConnectionsDelete ... +func (c WorkspacePrivateEndpointConnectionsClient) PrivateEndpointConnectionsDelete(ctx context.Context, id PrivateEndpointConnectionId) (result PrivateEndpointConnectionsDeleteOperationResponse, 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/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/method_privateendpointconnectionsget.go b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/method_privateendpointconnectionsget.go new file mode 100644 index 00000000000..f7aa9bd0806 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/method_privateendpointconnectionsget.go @@ -0,0 +1,53 @@ +package workspaceprivateendpointconnections + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionsGetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateEndpointConnection +} + +// PrivateEndpointConnectionsGet ... +func (c WorkspacePrivateEndpointConnectionsClient) PrivateEndpointConnectionsGet(ctx context.Context, id PrivateEndpointConnectionId) (result PrivateEndpointConnectionsGetOperationResponse, 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/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/model_privateendpoint.go b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/model_privateendpoint.go new file mode 100644 index 00000000000..46e7b7482a8 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/model_privateendpoint.go @@ -0,0 +1,8 @@ +package workspaceprivateendpointconnections + +// 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/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/model_privateendpointconnection.go b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/model_privateendpointconnection.go new file mode 100644 index 00000000000..0d037176766 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/model_privateendpointconnection.go @@ -0,0 +1,21 @@ +package workspaceprivateendpointconnections + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/model_privateendpointconnectionproperties.go b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..ce93dd4413e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/model_privateendpointconnectionproperties.go @@ -0,0 +1,10 @@ +package workspaceprivateendpointconnections + +// 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/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/model_privatelinkserviceconnectionstate.go b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..48130af33e9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package workspaceprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/model_sku.go b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/model_sku.go new file mode 100644 index 00000000000..92fff419fc9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/model_sku.go @@ -0,0 +1,12 @@ +package workspaceprivateendpointconnections + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Name string `json:"name"` + Size *string `json:"size,omitempty"` + Tier *SkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/version.go b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/version.go new file mode 100644 index 00000000000..53e62e670ab --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaceprivateendpointconnections/version.go @@ -0,0 +1,10 @@ +package workspaceprivateendpointconnections + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/workspaceprivateendpointconnections/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/README.md b/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/README.md new file mode 100644 index 00000000000..c89f7f35964 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/README.md @@ -0,0 +1,36 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources` Documentation + +The `workspaceprivatelinkresources` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources" +``` + + +### Client Initialization + +```go +client := workspaceprivatelinkresources.NewWorkspacePrivateLinkResourcesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WorkspacePrivateLinkResourcesClient.PrivateLinkResourcesList` + +```go +ctx := context.TODO() +id := workspaceprivatelinkresources.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.PrivateLinkResourcesList(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/machinelearningservices/2025-04-01/workspaceprivatelinkresources/client.go b/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/client.go new file mode 100644 index 00000000000..d315e1e2908 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/client.go @@ -0,0 +1,26 @@ +package workspaceprivatelinkresources + +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 WorkspacePrivateLinkResourcesClient struct { + Client *resourcemanager.Client +} + +func NewWorkspacePrivateLinkResourcesClientWithBaseURI(sdkApi sdkEnv.Api) (*WorkspacePrivateLinkResourcesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "workspaceprivatelinkresources", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkspacePrivateLinkResourcesClient: %+v", err) + } + + return &WorkspacePrivateLinkResourcesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/constants.go b/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/constants.go new file mode 100644 index 00000000000..65252a4d7c9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/constants.go @@ -0,0 +1,57 @@ +package workspaceprivatelinkresources + +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 SkuTier string + +const ( + SkuTierBasic SkuTier = "Basic" + SkuTierFree SkuTier = "Free" + SkuTierPremium SkuTier = "Premium" + SkuTierStandard SkuTier = "Standard" +) + +func PossibleValuesForSkuTier() []string { + return []string{ + string(SkuTierBasic), + string(SkuTierFree), + string(SkuTierPremium), + string(SkuTierStandard), + } +} + +func (s *SkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuTier(input string) (*SkuTier, error) { + vals := map[string]SkuTier{ + "basic": SkuTierBasic, + "free": SkuTierFree, + "premium": SkuTierPremium, + "standard": SkuTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuTier(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/id_workspace.go b/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/id_workspace.go new file mode 100644 index 00000000000..bb7f7cf7926 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/id_workspace.go @@ -0,0 +1,130 @@ +package workspaceprivatelinkresources + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/id_workspace_test.go b/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/id_workspace_test.go new file mode 100644 index 00000000000..1c878565e80 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/id_workspace_test.go @@ -0,0 +1,282 @@ +package workspaceprivatelinkresources + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/method_privatelinkresourceslist.go b/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/method_privatelinkresourceslist.go new file mode 100644 index 00000000000..91299f85e41 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/method_privatelinkresourceslist.go @@ -0,0 +1,54 @@ +package workspaceprivatelinkresources + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourcesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *PrivateLinkResourceListResult +} + +// PrivateLinkResourcesList ... +func (c WorkspacePrivateLinkResourcesClient) PrivateLinkResourcesList(ctx context.Context, id WorkspaceId) (result PrivateLinkResourcesListOperationResponse, 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 PrivateLinkResourceListResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/model_privatelinkresource.go b/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/model_privatelinkresource.go new file mode 100644 index 00000000000..05d965b34b5 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/model_privatelinkresource.go @@ -0,0 +1,21 @@ +package workspaceprivatelinkresources + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResource struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateLinkResourceProperties `json:"properties,omitempty"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/model_privatelinkresourcelistresult.go b/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/model_privatelinkresourcelistresult.go new file mode 100644 index 00000000000..18e565fbb9c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/model_privatelinkresourcelistresult.go @@ -0,0 +1,8 @@ +package workspaceprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceListResult struct { + Value *[]PrivateLinkResource `json:"value,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/model_privatelinkresourceproperties.go b/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/model_privatelinkresourceproperties.go new file mode 100644 index 00000000000..d35bf214592 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/model_privatelinkresourceproperties.go @@ -0,0 +1,10 @@ +package workspaceprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkResourceProperties struct { + GroupId *string `json:"groupId,omitempty"` + RequiredMembers *[]string `json:"requiredMembers,omitempty"` + RequiredZoneNames *[]string `json:"requiredZoneNames,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/model_sku.go b/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/model_sku.go new file mode 100644 index 00000000000..a7766efe350 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/model_sku.go @@ -0,0 +1,12 @@ +package workspaceprivatelinkresources + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Name string `json:"name"` + Size *string `json:"size,omitempty"` + Tier *SkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/version.go b/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/version.go new file mode 100644 index 00000000000..d9abfeed069 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaceprivatelinkresources/version.go @@ -0,0 +1,10 @@ +package workspaceprivatelinkresources + +// 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-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/workspaceprivatelinkresources/2025-04-01" +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/README.md b/resource-manager/machinelearningservices/2025-04-01/workspaces/README.md new file mode 100644 index 00000000000..e1349e65176 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/README.md @@ -0,0 +1,195 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/workspaces` Documentation + +The `workspaces` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2025-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2025-04-01/workspaces" +``` + + +### Client Initialization + +```go +client := workspaces.NewWorkspacesClientWithBaseURI("https://management.azure.com") +client.Client.Authorizer = authorizer +``` + + +### Example Usage: `WorkspacesClient.CreateOrUpdate` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +payload := workspaces.Workspace{ + // ... +} + + +if err := client.CreateOrUpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WorkspacesClient.Delete` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +if err := client.DeleteThenPoll(ctx, id, workspaces.DefaultDeleteOperationOptions()); err != nil { + // handle the error +} +``` + + +### Example Usage: `WorkspacesClient.Diagnose` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +payload := workspaces.DiagnoseWorkspaceParameters{ + // ... +} + + +if err := client.DiagnoseThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WorkspacesClient.Get` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +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: `WorkspacesClient.ListByResourceGroup` + +```go +ctx := context.TODO() +id := commonids.NewResourceGroupID("12345678-1234-9876-4563-123456789012", "example-resource-group") + +// alternatively `client.ListByResourceGroup(ctx, id, workspaces.DefaultListByResourceGroupOperationOptions())` can be used to do batched pagination +items, err := client.ListByResourceGroupComplete(ctx, id, workspaces.DefaultListByResourceGroupOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkspacesClient.ListBySubscription` + +```go +ctx := context.TODO() +id := commonids.NewSubscriptionID("12345678-1234-9876-4563-123456789012") + +// alternatively `client.ListBySubscription(ctx, id, workspaces.DefaultListBySubscriptionOperationOptions())` can be used to do batched pagination +items, err := client.ListBySubscriptionComplete(ctx, id, workspaces.DefaultListBySubscriptionOperationOptions()) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` + + +### Example Usage: `WorkspacesClient.ListKeys` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.ListKeys(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkspacesClient.ListNotebookAccessToken` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +read, err := client.ListNotebookAccessToken(ctx, id) +if err != nil { + // handle the error +} +if model := read.Model; model != nil { + // do something with the model/response object +} +``` + + +### Example Usage: `WorkspacesClient.ResyncKeys` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +if err := client.ResyncKeysThenPoll(ctx, id); err != nil { + // handle the error +} +``` + + +### Example Usage: `WorkspacesClient.Update` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +payload := workspaces.WorkspaceUpdateParameters{ + // ... +} + + +if err := client.UpdateThenPoll(ctx, id, payload); err != nil { + // handle the error +} +``` + + +### Example Usage: `WorkspacesClient.WorkspaceFeaturesList` + +```go +ctx := context.TODO() +id := workspaces.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + +// alternatively `client.WorkspaceFeaturesList(ctx, id)` can be used to do batched pagination +items, err := client.WorkspaceFeaturesListComplete(ctx, id) +if err != nil { + // handle the error +} +for _, item := range items { + // do something +} +``` diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/client.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/client.go new file mode 100644 index 00000000000..c6ef3485d22 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/client.go @@ -0,0 +1,26 @@ +package workspaces + +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 WorkspacesClient struct { + Client *resourcemanager.Client +} + +func NewWorkspacesClientWithBaseURI(sdkApi sdkEnv.Api) (*WorkspacesClient, error) { + client, err := resourcemanager.NewClient(sdkApi, "workspaces", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating WorkspacesClient: %+v", err) + } + + return &WorkspacesClient{ + Client: client, + }, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/constants.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/constants.go new file mode 100644 index 00000000000..4c016b2ef61 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/constants.go @@ -0,0 +1,685 @@ +package workspaces + +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 DiagnoseResultLevel string + +const ( + DiagnoseResultLevelError DiagnoseResultLevel = "Error" + DiagnoseResultLevelInformation DiagnoseResultLevel = "Information" + DiagnoseResultLevelWarning DiagnoseResultLevel = "Warning" +) + +func PossibleValuesForDiagnoseResultLevel() []string { + return []string{ + string(DiagnoseResultLevelError), + string(DiagnoseResultLevelInformation), + string(DiagnoseResultLevelWarning), + } +} + +func (s *DiagnoseResultLevel) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseDiagnoseResultLevel(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseDiagnoseResultLevel(input string) (*DiagnoseResultLevel, error) { + vals := map[string]DiagnoseResultLevel{ + "error": DiagnoseResultLevelError, + "information": DiagnoseResultLevelInformation, + "warning": DiagnoseResultLevelWarning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := DiagnoseResultLevel(input) + return &out, nil +} + +type EncryptionStatus string + +const ( + EncryptionStatusDisabled EncryptionStatus = "Disabled" + EncryptionStatusEnabled EncryptionStatus = "Enabled" +) + +func PossibleValuesForEncryptionStatus() []string { + return []string{ + string(EncryptionStatusDisabled), + string(EncryptionStatusEnabled), + } +} + +func (s *EncryptionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseEncryptionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseEncryptionStatus(input string) (*EncryptionStatus, error) { + vals := map[string]EncryptionStatus{ + "disabled": EncryptionStatusDisabled, + "enabled": EncryptionStatusEnabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := EncryptionStatus(input) + return &out, nil +} + +type FirewallSku string + +const ( + FirewallSkuBasic FirewallSku = "Basic" + FirewallSkuStandard FirewallSku = "Standard" +) + +func PossibleValuesForFirewallSku() []string { + return []string{ + string(FirewallSkuBasic), + string(FirewallSkuStandard), + } +} + +func (s *FirewallSku) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseFirewallSku(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseFirewallSku(input string) (*FirewallSku, error) { + vals := map[string]FirewallSku{ + "basic": FirewallSkuBasic, + "standard": FirewallSkuStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := FirewallSku(input) + return &out, nil +} + +type IsolationMode string + +const ( + IsolationModeAllowInternetOutbound IsolationMode = "AllowInternetOutbound" + IsolationModeAllowOnlyApprovedOutbound IsolationMode = "AllowOnlyApprovedOutbound" + IsolationModeDisabled IsolationMode = "Disabled" +) + +func PossibleValuesForIsolationMode() []string { + return []string{ + string(IsolationModeAllowInternetOutbound), + string(IsolationModeAllowOnlyApprovedOutbound), + string(IsolationModeDisabled), + } +} + +func (s *IsolationMode) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseIsolationMode(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseIsolationMode(input string) (*IsolationMode, error) { + vals := map[string]IsolationMode{ + "allowinternetoutbound": IsolationModeAllowInternetOutbound, + "allowonlyapprovedoutbound": IsolationModeAllowOnlyApprovedOutbound, + "disabled": IsolationModeDisabled, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := IsolationMode(input) + return &out, nil +} + +type ManagedNetworkKind string + +const ( + ManagedNetworkKindVOne ManagedNetworkKind = "V1" + ManagedNetworkKindVTwo ManagedNetworkKind = "V2" +) + +func PossibleValuesForManagedNetworkKind() []string { + return []string{ + string(ManagedNetworkKindVOne), + string(ManagedNetworkKindVTwo), + } +} + +func (s *ManagedNetworkKind) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedNetworkKind(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedNetworkKind(input string) (*ManagedNetworkKind, error) { + vals := map[string]ManagedNetworkKind{ + "v1": ManagedNetworkKindVOne, + "v2": ManagedNetworkKindVTwo, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedNetworkKind(input) + return &out, nil +} + +type ManagedNetworkStatus string + +const ( + ManagedNetworkStatusActive ManagedNetworkStatus = "Active" + ManagedNetworkStatusInactive ManagedNetworkStatus = "Inactive" +) + +func PossibleValuesForManagedNetworkStatus() []string { + return []string{ + string(ManagedNetworkStatusActive), + string(ManagedNetworkStatusInactive), + } +} + +func (s *ManagedNetworkStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseManagedNetworkStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseManagedNetworkStatus(input string) (*ManagedNetworkStatus, error) { + vals := map[string]ManagedNetworkStatus{ + "active": ManagedNetworkStatusActive, + "inactive": ManagedNetworkStatusInactive, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ManagedNetworkStatus(input) + return &out, nil +} + +type PrivateEndpointConnectionProvisioningState string + +const ( + PrivateEndpointConnectionProvisioningStateCreating PrivateEndpointConnectionProvisioningState = "Creating" + PrivateEndpointConnectionProvisioningStateDeleting PrivateEndpointConnectionProvisioningState = "Deleting" + PrivateEndpointConnectionProvisioningStateFailed PrivateEndpointConnectionProvisioningState = "Failed" + PrivateEndpointConnectionProvisioningStateSucceeded PrivateEndpointConnectionProvisioningState = "Succeeded" +) + +func PossibleValuesForPrivateEndpointConnectionProvisioningState() []string { + return []string{ + string(PrivateEndpointConnectionProvisioningStateCreating), + string(PrivateEndpointConnectionProvisioningStateDeleting), + string(PrivateEndpointConnectionProvisioningStateFailed), + string(PrivateEndpointConnectionProvisioningStateSucceeded), + } +} + +func (s *PrivateEndpointConnectionProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointConnectionProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointConnectionProvisioningState(input string) (*PrivateEndpointConnectionProvisioningState, error) { + vals := map[string]PrivateEndpointConnectionProvisioningState{ + "creating": PrivateEndpointConnectionProvisioningStateCreating, + "deleting": PrivateEndpointConnectionProvisioningStateDeleting, + "failed": PrivateEndpointConnectionProvisioningStateFailed, + "succeeded": PrivateEndpointConnectionProvisioningStateSucceeded, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointConnectionProvisioningState(input) + return &out, nil +} + +type PrivateEndpointServiceConnectionStatus string + +const ( + PrivateEndpointServiceConnectionStatusApproved PrivateEndpointServiceConnectionStatus = "Approved" + PrivateEndpointServiceConnectionStatusDisconnected PrivateEndpointServiceConnectionStatus = "Disconnected" + PrivateEndpointServiceConnectionStatusPending PrivateEndpointServiceConnectionStatus = "Pending" + PrivateEndpointServiceConnectionStatusRejected PrivateEndpointServiceConnectionStatus = "Rejected" + PrivateEndpointServiceConnectionStatusTimeout PrivateEndpointServiceConnectionStatus = "Timeout" +) + +func PossibleValuesForPrivateEndpointServiceConnectionStatus() []string { + return []string{ + string(PrivateEndpointServiceConnectionStatusApproved), + string(PrivateEndpointServiceConnectionStatusDisconnected), + string(PrivateEndpointServiceConnectionStatusPending), + string(PrivateEndpointServiceConnectionStatusRejected), + string(PrivateEndpointServiceConnectionStatusTimeout), + } +} + +func (s *PrivateEndpointServiceConnectionStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parsePrivateEndpointServiceConnectionStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parsePrivateEndpointServiceConnectionStatus(input string) (*PrivateEndpointServiceConnectionStatus, error) { + vals := map[string]PrivateEndpointServiceConnectionStatus{ + "approved": PrivateEndpointServiceConnectionStatusApproved, + "disconnected": PrivateEndpointServiceConnectionStatusDisconnected, + "pending": PrivateEndpointServiceConnectionStatusPending, + "rejected": PrivateEndpointServiceConnectionStatusRejected, + "timeout": PrivateEndpointServiceConnectionStatusTimeout, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := PrivateEndpointServiceConnectionStatus(input) + return &out, nil +} + +type ProvisioningState string + +const ( + ProvisioningStateCanceled ProvisioningState = "Canceled" + ProvisioningStateCreating ProvisioningState = "Creating" + ProvisioningStateDeleting ProvisioningState = "Deleting" + ProvisioningStateFailed ProvisioningState = "Failed" + ProvisioningStateSucceeded ProvisioningState = "Succeeded" + ProvisioningStateUnknown ProvisioningState = "Unknown" + ProvisioningStateUpdating ProvisioningState = "Updating" +) + +func PossibleValuesForProvisioningState() []string { + return []string{ + string(ProvisioningStateCanceled), + string(ProvisioningStateCreating), + string(ProvisioningStateDeleting), + string(ProvisioningStateFailed), + string(ProvisioningStateSucceeded), + string(ProvisioningStateUnknown), + string(ProvisioningStateUpdating), + } +} + +func (s *ProvisioningState) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseProvisioningState(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseProvisioningState(input string) (*ProvisioningState, error) { + vals := map[string]ProvisioningState{ + "canceled": ProvisioningStateCanceled, + "creating": ProvisioningStateCreating, + "deleting": ProvisioningStateDeleting, + "failed": ProvisioningStateFailed, + "succeeded": ProvisioningStateSucceeded, + "unknown": ProvisioningStateUnknown, + "updating": ProvisioningStateUpdating, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := ProvisioningState(input) + return &out, nil +} + +type 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 RuleAction string + +const ( + RuleActionAllow RuleAction = "Allow" + RuleActionDeny RuleAction = "Deny" +) + +func PossibleValuesForRuleAction() []string { + return []string{ + string(RuleActionAllow), + string(RuleActionDeny), + } +} + +func (s *RuleAction) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRuleAction(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRuleAction(input string) (*RuleAction, error) { + vals := map[string]RuleAction{ + "allow": RuleActionAllow, + "deny": RuleActionDeny, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RuleAction(input) + return &out, nil +} + +type RuleCategory string + +const ( + RuleCategoryDependency RuleCategory = "Dependency" + RuleCategoryRecommended RuleCategory = "Recommended" + RuleCategoryRequired RuleCategory = "Required" + RuleCategoryUserDefined RuleCategory = "UserDefined" +) + +func PossibleValuesForRuleCategory() []string { + return []string{ + string(RuleCategoryDependency), + string(RuleCategoryRecommended), + string(RuleCategoryRequired), + string(RuleCategoryUserDefined), + } +} + +func (s *RuleCategory) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRuleCategory(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRuleCategory(input string) (*RuleCategory, error) { + vals := map[string]RuleCategory{ + "dependency": RuleCategoryDependency, + "recommended": RuleCategoryRecommended, + "required": RuleCategoryRequired, + "userdefined": RuleCategoryUserDefined, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RuleCategory(input) + return &out, nil +} + +type RuleStatus string + +const ( + RuleStatusActive RuleStatus = "Active" + RuleStatusDeleting RuleStatus = "Deleting" + RuleStatusFailed RuleStatus = "Failed" + RuleStatusInactive RuleStatus = "Inactive" + RuleStatusProvisioning RuleStatus = "Provisioning" +) + +func PossibleValuesForRuleStatus() []string { + return []string{ + string(RuleStatusActive), + string(RuleStatusDeleting), + string(RuleStatusFailed), + string(RuleStatusInactive), + string(RuleStatusProvisioning), + } +} + +func (s *RuleStatus) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRuleStatus(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRuleStatus(input string) (*RuleStatus, error) { + vals := map[string]RuleStatus{ + "active": RuleStatusActive, + "deleting": RuleStatusDeleting, + "failed": RuleStatusFailed, + "inactive": RuleStatusInactive, + "provisioning": RuleStatusProvisioning, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RuleStatus(input) + return &out, nil +} + +type RuleType string + +const ( + RuleTypeFQDN RuleType = "FQDN" + RuleTypePrivateEndpoint RuleType = "PrivateEndpoint" + RuleTypeServiceTag RuleType = "ServiceTag" +) + +func PossibleValuesForRuleType() []string { + return []string{ + string(RuleTypeFQDN), + string(RuleTypePrivateEndpoint), + string(RuleTypeServiceTag), + } +} + +func (s *RuleType) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseRuleType(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseRuleType(input string) (*RuleType, error) { + vals := map[string]RuleType{ + "fqdn": RuleTypeFQDN, + "privateendpoint": RuleTypePrivateEndpoint, + "servicetag": RuleTypeServiceTag, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := RuleType(input) + return &out, nil +} + +type SkuTier string + +const ( + SkuTierBasic SkuTier = "Basic" + SkuTierFree SkuTier = "Free" + SkuTierPremium SkuTier = "Premium" + SkuTierStandard SkuTier = "Standard" +) + +func PossibleValuesForSkuTier() []string { + return []string{ + string(SkuTierBasic), + string(SkuTierFree), + string(SkuTierPremium), + string(SkuTierStandard), + } +} + +func (s *SkuTier) UnmarshalJSON(bytes []byte) error { + var decoded string + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + out, err := parseSkuTier(decoded) + if err != nil { + return fmt.Errorf("parsing %q: %+v", decoded, err) + } + *s = *out + return nil +} + +func parseSkuTier(input string) (*SkuTier, error) { + vals := map[string]SkuTier{ + "basic": SkuTierBasic, + "free": SkuTierFree, + "premium": SkuTierPremium, + "standard": SkuTierStandard, + } + if v, ok := vals[strings.ToLower(input)]; ok { + return &v, nil + } + + // otherwise presume it's an undefined value and best-effort it + out := SkuTier(input) + return &out, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/id_workspace.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/id_workspace.go new file mode 100644 index 00000000000..4a4ee817b3a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/id_workspace.go @@ -0,0 +1,130 @@ +package workspaces + +import ( + "fmt" + "strings" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/recaser" + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +func init() { + recaser.RegisterResourceId(&WorkspaceId{}) +} + +var _ resourceids.ResourceId = &WorkspaceId{} + +// WorkspaceId is a struct representing the Resource ID for a Workspace +type WorkspaceId struct { + SubscriptionId string + ResourceGroupName string + WorkspaceName string +} + +// NewWorkspaceID returns a new WorkspaceId struct +func NewWorkspaceID(subscriptionId string, resourceGroupName string, workspaceName string) WorkspaceId { + return WorkspaceId{ + SubscriptionId: subscriptionId, + ResourceGroupName: resourceGroupName, + WorkspaceName: workspaceName, + } +} + +// ParseWorkspaceID parses 'input' into a WorkspaceId +func ParseWorkspaceID(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, false) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +// ParseWorkspaceIDInsensitively parses 'input' case-insensitively into a WorkspaceId +// note: this method should only be used for API response data and not user input +func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { + parser := resourceids.NewParserFromResourceIdType(&WorkspaceId{}) + parsed, err := parser.Parse(input, true) + if err != nil { + return nil, fmt.Errorf("parsing %q: %+v", input, err) + } + + id := WorkspaceId{} + if err = id.FromParseResult(*parsed); err != nil { + return nil, err + } + + return &id, nil +} + +func (id *WorkspaceId) FromParseResult(input resourceids.ParseResult) error { + var ok bool + + if id.SubscriptionId, ok = input.Parsed["subscriptionId"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "subscriptionId", input) + } + + if id.ResourceGroupName, ok = input.Parsed["resourceGroupName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "resourceGroupName", input) + } + + if id.WorkspaceName, ok = input.Parsed["workspaceName"]; !ok { + return resourceids.NewSegmentNotSpecifiedError(id, "workspaceName", input) + } + + return nil +} + +// ValidateWorkspaceID checks that 'input' can be parsed as a Workspace ID +func ValidateWorkspaceID(input interface{}, key string) (warnings []string, errors []error) { + v, ok := input.(string) + if !ok { + errors = append(errors, fmt.Errorf("expected %q to be a string", key)) + return + } + + if _, err := ParseWorkspaceID(v); err != nil { + errors = append(errors, err) + } + + return +} + +// ID returns the formatted Workspace ID +func (id WorkspaceId) ID() string { + fmtString := "/subscriptions/%s/resourceGroups/%s/providers/Microsoft.MachineLearningServices/workspaces/%s" + return fmt.Sprintf(fmtString, id.SubscriptionId, id.ResourceGroupName, id.WorkspaceName) +} + +// Segments returns a slice of Resource ID Segments which comprise this Workspace ID +func (id WorkspaceId) Segments() []resourceids.Segment { + return []resourceids.Segment{ + resourceids.StaticSegment("staticSubscriptions", "subscriptions", "subscriptions"), + resourceids.SubscriptionIdSegment("subscriptionId", "12345678-1234-9876-4563-123456789012"), + resourceids.StaticSegment("staticResourceGroups", "resourceGroups", "resourceGroups"), + resourceids.ResourceGroupSegment("resourceGroupName", "example-resource-group"), + resourceids.StaticSegment("staticProviders", "providers", "providers"), + resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), + resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), + } +} + +// String returns a human-readable description of this Workspace ID +func (id WorkspaceId) String() string { + components := []string{ + fmt.Sprintf("Subscription: %q", id.SubscriptionId), + fmt.Sprintf("Resource Group Name: %q", id.ResourceGroupName), + fmt.Sprintf("Workspace Name: %q", id.WorkspaceName), + } + return fmt.Sprintf("Workspace (%s)", strings.Join(components, "\n")) +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/id_workspace_test.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/id_workspace_test.go new file mode 100644 index 00000000000..e704cbe9cc7 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/id_workspace_test.go @@ -0,0 +1,282 @@ +package workspaces + +import ( + "testing" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/resourceids" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ resourceids.ResourceId = &WorkspaceId{} + +func TestNewWorkspaceID(t *testing.T) { + id := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") + + if id.SubscriptionId != "12345678-1234-9876-4563-123456789012" { + t.Fatalf("Expected %q but got %q for Segment 'SubscriptionId'", id.SubscriptionId, "12345678-1234-9876-4563-123456789012") + } + + if id.ResourceGroupName != "example-resource-group" { + t.Fatalf("Expected %q but got %q for Segment 'ResourceGroupName'", id.ResourceGroupName, "example-resource-group") + } + + if id.WorkspaceName != "workspaceName" { + t.Fatalf("Expected %q but got %q for Segment 'WorkspaceName'", id.WorkspaceName, "workspaceName") + } +} + +func TestFormatWorkspaceID(t *testing.T) { + actual := NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName").ID() + expected := "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName" + if actual != expected { + t.Fatalf("Expected the Formatted ID to be %q but got %q", expected, actual) + } +} + +func TestParseWorkspaceID(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceID(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestParseWorkspaceIDInsensitively(t *testing.T) { + testData := []struct { + Input string + Error bool + Expected *WorkspaceId + }{ + { + // Incomplete URI + Input: "", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs", + Error: true, + }, + { + // Incomplete URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces", + Error: true, + }, + { + // Incomplete URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS", + Error: true, + }, + { + // Valid URI + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "example-resource-group", + WorkspaceName: "workspaceName", + }, + }, + { + // Invalid (Valid Uri with Extra segment) + Input: "/subscriptions/12345678-1234-9876-4563-123456789012/resourceGroups/example-resource-group/providers/Microsoft.MachineLearningServices/workspaces/workspaceName/extra", + Error: true, + }, + { + // Valid URI (mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe", + Expected: &WorkspaceId{ + SubscriptionId: "12345678-1234-9876-4563-123456789012", + ResourceGroupName: "eXaMpLe-rEsOuRcE-GrOuP", + WorkspaceName: "wOrKsPaCeNaMe", + }, + }, + { + // Invalid (Valid Uri with Extra segment - mIxEd CaSe since this is insensitive) + Input: "/sUbScRiPtIoNs/12345678-1234-9876-4563-123456789012/rEsOuRcEgRoUpS/eXaMpLe-rEsOuRcE-GrOuP/pRoViDeRs/mIcRoSoFt.mAcHiNeLeArNiNgSeRvIcEs/wOrKsPaCeS/wOrKsPaCeNaMe/extra", + Error: true, + }, + } + for _, v := range testData { + t.Logf("[DEBUG] Testing %q", v.Input) + + actual, err := ParseWorkspaceIDInsensitively(v.Input) + if err != nil { + if v.Error { + continue + } + + t.Fatalf("Expect a value but got an error: %+v", err) + } + if v.Error { + t.Fatal("Expect an error but didn't get one") + } + + if actual.SubscriptionId != v.Expected.SubscriptionId { + t.Fatalf("Expected %q but got %q for SubscriptionId", v.Expected.SubscriptionId, actual.SubscriptionId) + } + + if actual.ResourceGroupName != v.Expected.ResourceGroupName { + t.Fatalf("Expected %q but got %q for ResourceGroupName", v.Expected.ResourceGroupName, actual.ResourceGroupName) + } + + if actual.WorkspaceName != v.Expected.WorkspaceName { + t.Fatalf("Expected %q but got %q for WorkspaceName", v.Expected.WorkspaceName, actual.WorkspaceName) + } + + } +} + +func TestSegmentsForWorkspaceId(t *testing.T) { + segments := WorkspaceId{}.Segments() + if len(segments) == 0 { + t.Fatalf("WorkspaceId has no segments") + } + + uniqueNames := make(map[string]struct{}, 0) + for _, segment := range segments { + uniqueNames[segment.Name] = struct{}{} + } + if len(uniqueNames) != len(segments) { + t.Fatalf("Expected the Segments to be unique but got %q unique segments and %d total segments", len(uniqueNames), len(segments)) + } +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/method_createorupdate.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/method_createorupdate.go new file mode 100644 index 00000000000..191b1989213 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/method_createorupdate.go @@ -0,0 +1,75 @@ +package workspaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *Workspace +} + +// CreateOrUpdate ... +func (c WorkspacesClient) CreateOrUpdate(ctx context.Context, id WorkspaceId, input Workspace) (result CreateOrUpdateOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPut, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// CreateOrUpdateThenPoll performs CreateOrUpdate then polls until it's completed +func (c WorkspacesClient) CreateOrUpdateThenPoll(ctx context.Context, id WorkspaceId, input Workspace) error { + result, err := c.CreateOrUpdate(ctx, id, input) + if err != nil { + return fmt.Errorf("performing CreateOrUpdate: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after CreateOrUpdate: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/method_delete.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/method_delete.go new file mode 100644 index 00000000000..5297485af30 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/method_delete.go @@ -0,0 +1,100 @@ +package workspaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 { + ForceToPurge *bool +} + +func DefaultDeleteOperationOptions() DeleteOperationOptions { + return DeleteOperationOptions{} +} + +func (o DeleteOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o DeleteOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o DeleteOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.ForceToPurge != nil { + out.Append("forceToPurge", fmt.Sprintf("%v", *o.ForceToPurge)) + } + return &out +} + +// Delete ... +func (c WorkspacesClient) Delete(ctx context.Context, id WorkspaceId, options DeleteOperationOptions) (result DeleteOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusNoContent, + http.StatusOK, + }, + HttpMethod: http.MethodDelete, + OptionsObject: options, + Path: id.ID(), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DeleteThenPoll performs Delete then polls until it's completed +func (c WorkspacesClient) DeleteThenPoll(ctx context.Context, id WorkspaceId, 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/machinelearningservices/2025-04-01/workspaces/method_diagnose.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/method_diagnose.go new file mode 100644 index 00000000000..9cb7d2fe49f --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/method_diagnose.go @@ -0,0 +1,75 @@ +package workspaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnoseOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData + Model *DiagnoseResponseResult +} + +// Diagnose ... +func (c WorkspacesClient) Diagnose(ctx context.Context, id WorkspaceId, input DiagnoseWorkspaceParameters) (result DiagnoseOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/diagnose", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + if err = req.Marshal(input); err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// DiagnoseThenPoll performs Diagnose then polls until it's completed +func (c WorkspacesClient) DiagnoseThenPoll(ctx context.Context, id WorkspaceId, input DiagnoseWorkspaceParameters) error { + result, err := c.Diagnose(ctx, id, input) + if err != nil { + return fmt.Errorf("performing Diagnose: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after Diagnose: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/method_get.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/method_get.go new file mode 100644 index 00000000000..532c4ea30f7 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/method_get.go @@ -0,0 +1,53 @@ +package workspaces + +import ( + "context" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type GetOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *Workspace +} + +// Get ... +func (c WorkspacesClient) Get(ctx context.Context, id WorkspaceId) (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 Workspace + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/method_listbyresourcegroup.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/method_listbyresourcegroup.go new file mode 100644 index 00000000000..dc63c4f42e7 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/method_listbyresourcegroup.go @@ -0,0 +1,135 @@ +package workspaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/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 *[]Workspace +} + +type ListByResourceGroupCompleteResult struct { + LatestHttpResponse *http.Response + Items []Workspace +} + +type ListByResourceGroupOperationOptions struct { + Skip *string +} + +func DefaultListByResourceGroupOperationOptions() ListByResourceGroupOperationOptions { + return ListByResourceGroupOperationOptions{} +} + +func (o ListByResourceGroupOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListByResourceGroupOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListByResourceGroupOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + return &out +} + +type ListByResourceGroupCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListByResourceGroupCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListByResourceGroup ... +func (c WorkspacesClient) ListByResourceGroup(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (result ListByResourceGroupOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListByResourceGroupCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.MachineLearningServices/workspaces", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Workspace `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 WorkspacesClient) ListByResourceGroupComplete(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions) (ListByResourceGroupCompleteResult, error) { + return c.ListByResourceGroupCompleteMatchingPredicate(ctx, id, options, WorkspaceOperationPredicate{}) +} + +// ListByResourceGroupCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkspacesClient) ListByResourceGroupCompleteMatchingPredicate(ctx context.Context, id commonids.ResourceGroupId, options ListByResourceGroupOperationOptions, predicate WorkspaceOperationPredicate) (result ListByResourceGroupCompleteResult, err error) { + items := make([]Workspace, 0) + + resp, err := c.ListByResourceGroup(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListByResourceGroupCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/method_listbysubscription.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/method_listbysubscription.go new file mode 100644 index 00000000000..39d3586061e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/method_listbysubscription.go @@ -0,0 +1,135 @@ +package workspaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-helpers/resourcemanager/commonids" + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListBySubscriptionOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]Workspace +} + +type ListBySubscriptionCompleteResult struct { + LatestHttpResponse *http.Response + Items []Workspace +} + +type ListBySubscriptionOperationOptions struct { + Skip *string +} + +func DefaultListBySubscriptionOperationOptions() ListBySubscriptionOperationOptions { + return ListBySubscriptionOperationOptions{} +} + +func (o ListBySubscriptionOperationOptions) ToHeaders() *client.Headers { + out := client.Headers{} + + return &out +} + +func (o ListBySubscriptionOperationOptions) ToOData() *odata.Query { + out := odata.Query{} + + return &out +} + +func (o ListBySubscriptionOperationOptions) ToQuery() *client.QueryParams { + out := client.QueryParams{} + if o.Skip != nil { + out.Append("$skip", fmt.Sprintf("%v", *o.Skip)) + } + return &out +} + +type ListBySubscriptionCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *ListBySubscriptionCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// ListBySubscription ... +func (c WorkspacesClient) ListBySubscription(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (result ListBySubscriptionOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + OptionsObject: options, + Pager: &ListBySubscriptionCustomPager{}, + Path: fmt.Sprintf("%s/providers/Microsoft.MachineLearningServices/workspaces", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]Workspace `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// ListBySubscriptionComplete retrieves all the results into a single object +func (c WorkspacesClient) ListBySubscriptionComplete(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions) (ListBySubscriptionCompleteResult, error) { + return c.ListBySubscriptionCompleteMatchingPredicate(ctx, id, options, WorkspaceOperationPredicate{}) +} + +// ListBySubscriptionCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkspacesClient) ListBySubscriptionCompleteMatchingPredicate(ctx context.Context, id commonids.SubscriptionId, options ListBySubscriptionOperationOptions, predicate WorkspaceOperationPredicate) (result ListBySubscriptionCompleteResult, err error) { + items := make([]Workspace, 0) + + resp, err := c.ListBySubscription(ctx, id, options) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = ListBySubscriptionCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/method_listkeys.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/method_listkeys.go new file mode 100644 index 00000000000..54b28298920 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/method_listkeys.go @@ -0,0 +1,54 @@ +package workspaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListKeysOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *ListWorkspaceKeysResult +} + +// ListKeys ... +func (c WorkspacesClient) ListKeys(ctx context.Context, id WorkspaceId) (result ListKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model ListWorkspaceKeysResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/method_listnotebookaccesstoken.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/method_listnotebookaccesstoken.go new file mode 100644 index 00000000000..d6f35efb8b2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/method_listnotebookaccesstoken.go @@ -0,0 +1,54 @@ +package workspaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListNotebookAccessTokenOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *NotebookAccessTokenResult +} + +// ListNotebookAccessToken ... +func (c WorkspacesClient) ListNotebookAccessToken(ctx context.Context, id WorkspaceId) (result ListNotebookAccessTokenOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/listNotebookAccessToken", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var model NotebookAccessTokenResult + result.Model = &model + if err = resp.Unmarshal(result.Model); err != nil { + return + } + + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/method_resynckeys.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/method_resynckeys.go new file mode 100644 index 00000000000..04df0c19b08 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/method_resynckeys.go @@ -0,0 +1,70 @@ +package workspaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ResyncKeysOperationResponse struct { + Poller pollers.Poller + HttpResponse *http.Response + OData *odata.OData +} + +// ResyncKeys ... +func (c WorkspacesClient) ResyncKeys(ctx context.Context, id WorkspaceId) (result ResyncKeysOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusAccepted, + http.StatusOK, + }, + HttpMethod: http.MethodPost, + Path: fmt.Sprintf("%s/resyncKeys", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.Execute(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + result.Poller, err = resourcemanager.PollerFromResponse(resp, c.Client) + if err != nil { + return + } + + return +} + +// ResyncKeysThenPoll performs ResyncKeys then polls until it's completed +func (c WorkspacesClient) ResyncKeysThenPoll(ctx context.Context, id WorkspaceId) error { + result, err := c.ResyncKeys(ctx, id) + if err != nil { + return fmt.Errorf("performing ResyncKeys: %+v", err) + } + + if err := result.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("polling after ResyncKeys: %+v", err) + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/method_update.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/method_update.go new file mode 100644 index 00000000000..254dda35cb6 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/method_update.go @@ -0,0 +1,75 @@ +package workspaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/client/pollers" + "github.com/hashicorp/go-azure-sdk/sdk/client/resourcemanager" + "github.com/hashicorp/go-azure-sdk/sdk/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 *Workspace +} + +// Update ... +func (c WorkspacesClient) Update(ctx context.Context, id WorkspaceId, input WorkspaceUpdateParameters) (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 WorkspacesClient) UpdateThenPoll(ctx context.Context, id WorkspaceId, input WorkspaceUpdateParameters) 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/machinelearningservices/2025-04-01/workspaces/method_workspacefeatureslist.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/method_workspacefeatureslist.go new file mode 100644 index 00000000000..3d048be572e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/method_workspacefeatureslist.go @@ -0,0 +1,105 @@ +package workspaces + +import ( + "context" + "fmt" + "net/http" + + "github.com/hashicorp/go-azure-sdk/sdk/client" + "github.com/hashicorp/go-azure-sdk/sdk/odata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceFeaturesListOperationResponse struct { + HttpResponse *http.Response + OData *odata.OData + Model *[]AmlUserFeature +} + +type WorkspaceFeaturesListCompleteResult struct { + LatestHttpResponse *http.Response + Items []AmlUserFeature +} + +type WorkspaceFeaturesListCustomPager struct { + NextLink *odata.Link `json:"nextLink"` +} + +func (p *WorkspaceFeaturesListCustomPager) NextPageLink() *odata.Link { + defer func() { + p.NextLink = nil + }() + + return p.NextLink +} + +// WorkspaceFeaturesList ... +func (c WorkspacesClient) WorkspaceFeaturesList(ctx context.Context, id WorkspaceId) (result WorkspaceFeaturesListOperationResponse, err error) { + opts := client.RequestOptions{ + ContentType: "application/json; charset=utf-8", + ExpectedStatusCodes: []int{ + http.StatusOK, + }, + HttpMethod: http.MethodGet, + Pager: &WorkspaceFeaturesListCustomPager{}, + Path: fmt.Sprintf("%s/features", id.ID()), + } + + req, err := c.Client.NewRequest(ctx, opts) + if err != nil { + return + } + + var resp *client.Response + resp, err = req.ExecutePaged(ctx) + if resp != nil { + result.OData = resp.OData + result.HttpResponse = resp.Response + } + if err != nil { + return + } + + var values struct { + Values *[]AmlUserFeature `json:"value"` + } + if err = resp.Unmarshal(&values); err != nil { + return + } + + result.Model = values.Values + + return +} + +// WorkspaceFeaturesListComplete retrieves all the results into a single object +func (c WorkspacesClient) WorkspaceFeaturesListComplete(ctx context.Context, id WorkspaceId) (WorkspaceFeaturesListCompleteResult, error) { + return c.WorkspaceFeaturesListCompleteMatchingPredicate(ctx, id, AmlUserFeatureOperationPredicate{}) +} + +// WorkspaceFeaturesListCompleteMatchingPredicate retrieves all the results and then applies the predicate +func (c WorkspacesClient) WorkspaceFeaturesListCompleteMatchingPredicate(ctx context.Context, id WorkspaceId, predicate AmlUserFeatureOperationPredicate) (result WorkspaceFeaturesListCompleteResult, err error) { + items := make([]AmlUserFeature, 0) + + resp, err := c.WorkspaceFeaturesList(ctx, id) + if err != nil { + result.LatestHttpResponse = resp.HttpResponse + err = fmt.Errorf("loading results: %+v", err) + return + } + if resp.Model != nil { + for _, v := range *resp.Model { + if predicate.Matches(v) { + items = append(items, v) + } + } + } + + result = WorkspaceFeaturesListCompleteResult{ + LatestHttpResponse: resp.HttpResponse, + Items: items, + } + return +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_amluserfeature.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_amluserfeature.go new file mode 100644 index 00000000000..ce034ac031c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_amluserfeature.go @@ -0,0 +1,10 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AmlUserFeature struct { + Description *string `json:"description,omitempty"` + DisplayName *string `json:"displayName,omitempty"` + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_computeruntimedto.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_computeruntimedto.go new file mode 100644 index 00000000000..358aa6c7855 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_computeruntimedto.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ComputeRuntimeDto struct { + SparkRuntimeVersion *string `json:"sparkRuntimeVersion,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_cosmosdbsettings.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_cosmosdbsettings.go new file mode 100644 index 00000000000..f1f754cfb7c --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_cosmosdbsettings.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type CosmosDbSettings struct { + CollectionsThroughput *int64 `json:"collectionsThroughput,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_diagnoserequestproperties.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_diagnoserequestproperties.go new file mode 100644 index 00000000000..f088a220b35 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_diagnoserequestproperties.go @@ -0,0 +1,16 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnoseRequestProperties struct { + ApplicationInsights *map[string]interface{} `json:"applicationInsights,omitempty"` + ContainerRegistry *map[string]interface{} `json:"containerRegistry,omitempty"` + DnsResolution *map[string]interface{} `json:"dnsResolution,omitempty"` + KeyVault *map[string]interface{} `json:"keyVault,omitempty"` + Nsg *map[string]interface{} `json:"nsg,omitempty"` + Others *map[string]interface{} `json:"others,omitempty"` + ResourceLock *map[string]interface{} `json:"resourceLock,omitempty"` + StorageAccount *map[string]interface{} `json:"storageAccount,omitempty"` + Udr *map[string]interface{} `json:"udr,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_diagnoseresponseresult.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_diagnoseresponseresult.go new file mode 100644 index 00000000000..4573147de8e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_diagnoseresponseresult.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnoseResponseResult struct { + Value *DiagnoseResponseResultValue `json:"value,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_diagnoseresponseresultvalue.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_diagnoseresponseresultvalue.go new file mode 100644 index 00000000000..bd00a772cc4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_diagnoseresponseresultvalue.go @@ -0,0 +1,16 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnoseResponseResultValue struct { + ApplicationInsightsResults *[]DiagnoseResult `json:"applicationInsightsResults,omitempty"` + ContainerRegistryResults *[]DiagnoseResult `json:"containerRegistryResults,omitempty"` + DnsResolutionResults *[]DiagnoseResult `json:"dnsResolutionResults,omitempty"` + KeyVaultResults *[]DiagnoseResult `json:"keyVaultResults,omitempty"` + NetworkSecurityRuleResults *[]DiagnoseResult `json:"networkSecurityRuleResults,omitempty"` + OtherResults *[]DiagnoseResult `json:"otherResults,omitempty"` + ResourceLockResults *[]DiagnoseResult `json:"resourceLockResults,omitempty"` + StorageAccountResults *[]DiagnoseResult `json:"storageAccountResults,omitempty"` + UserDefinedRouteResults *[]DiagnoseResult `json:"userDefinedRouteResults,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_diagnoseresult.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_diagnoseresult.go new file mode 100644 index 00000000000..7bb1f52bee4 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_diagnoseresult.go @@ -0,0 +1,10 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnoseResult struct { + Code *string `json:"code,omitempty"` + Level *DiagnoseResultLevel `json:"level,omitempty"` + Message *string `json:"message,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_diagnoseworkspaceparameters.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_diagnoseworkspaceparameters.go new file mode 100644 index 00000000000..e74877f4cbd --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_diagnoseworkspaceparameters.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type DiagnoseWorkspaceParameters struct { + Value *DiagnoseRequestProperties `json:"value,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_encryptionkeyvaultproperties.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_encryptionkeyvaultproperties.go new file mode 100644 index 00000000000..eaffc7fe261 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_encryptionkeyvaultproperties.go @@ -0,0 +1,10 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionKeyVaultProperties struct { + IdentityClientId *string `json:"identityClientId,omitempty"` + KeyIdentifier string `json:"keyIdentifier"` + KeyVaultArmId string `json:"keyVaultArmId"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_encryptionkeyvaultupdateproperties.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_encryptionkeyvaultupdateproperties.go new file mode 100644 index 00000000000..64e40fec2e2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_encryptionkeyvaultupdateproperties.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionKeyVaultUpdateProperties struct { + KeyIdentifier string `json:"keyIdentifier"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_encryptionproperty.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_encryptionproperty.go new file mode 100644 index 00000000000..63ca950b635 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_encryptionproperty.go @@ -0,0 +1,10 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionProperty struct { + Identity *IdentityForCmk `json:"identity,omitempty"` + KeyVaultProperties EncryptionKeyVaultProperties `json:"keyVaultProperties"` + Status EncryptionStatus `json:"status"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_encryptionupdateproperties.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_encryptionupdateproperties.go new file mode 100644 index 00000000000..9188301a361 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_encryptionupdateproperties.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type EncryptionUpdateProperties struct { + KeyVaultProperties EncryptionKeyVaultUpdateProperties `json:"keyVaultProperties"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_featurestoresettings.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_featurestoresettings.go new file mode 100644 index 00000000000..8a7212d2c26 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_featurestoresettings.go @@ -0,0 +1,10 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type FeatureStoreSettings struct { + ComputeRuntime *ComputeRuntimeDto `json:"computeRuntime,omitempty"` + OfflineStoreConnectionName *string `json:"offlineStoreConnectionName,omitempty"` + OnlineStoreConnectionName *string `json:"onlineStoreConnectionName,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_fqdnoutboundrule.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_fqdnoutboundrule.go new file mode 100644 index 00000000000..925b564f9fc --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_fqdnoutboundrule.go @@ -0,0 +1,58 @@ +package workspaces + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ OutboundRule = FqdnOutboundRule{} + +type FqdnOutboundRule struct { + Destination *string `json:"destination,omitempty"` + + // Fields inherited from OutboundRule + + Category *RuleCategory `json:"category,omitempty"` + ErrorInformation *string `json:"errorInformation,omitempty"` + ParentRuleNames *[]string `json:"parentRuleNames,omitempty"` + Status *RuleStatus `json:"status,omitempty"` + Type RuleType `json:"type"` +} + +func (s FqdnOutboundRule) OutboundRule() BaseOutboundRuleImpl { + return BaseOutboundRuleImpl{ + Category: s.Category, + ErrorInformation: s.ErrorInformation, + ParentRuleNames: s.ParentRuleNames, + Status: s.Status, + Type: s.Type, + } +} + +var _ json.Marshaler = FqdnOutboundRule{} + +func (s FqdnOutboundRule) MarshalJSON() ([]byte, error) { + type wrapper FqdnOutboundRule + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling FqdnOutboundRule: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling FqdnOutboundRule: %+v", err) + } + + decoded["type"] = "FQDN" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling FqdnOutboundRule: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_identityforcmk.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_identityforcmk.go new file mode 100644 index 00000000000..288f4d6cdc9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_identityforcmk.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type IdentityForCmk struct { + UserAssignedIdentity *string `json:"userAssignedIdentity,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_listnotebookkeysresult.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_listnotebookkeysresult.go new file mode 100644 index 00000000000..41ce8e2dae7 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_listnotebookkeysresult.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListNotebookKeysResult struct { + PrimaryAccessKey *string `json:"primaryAccessKey,omitempty"` + SecondaryAccessKey *string `json:"secondaryAccessKey,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_listworkspacekeysresult.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_listworkspacekeysresult.go new file mode 100644 index 00000000000..112c5d97a70 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_listworkspacekeysresult.go @@ -0,0 +1,12 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ListWorkspaceKeysResult struct { + AppInsightsInstrumentationKey *string `json:"appInsightsInstrumentationKey,omitempty"` + ContainerRegistryCredentials *RegistryListCredentialsResult `json:"containerRegistryCredentials,omitempty"` + NotebookAccessKeys *ListNotebookKeysResult `json:"notebookAccessKeys,omitempty"` + UserStorageKey *string `json:"userStorageKey,omitempty"` + UserStorageResourceId *string `json:"userStorageResourceId,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_managednetworkprovisionstatus.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_managednetworkprovisionstatus.go new file mode 100644 index 00000000000..5a5181c2770 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_managednetworkprovisionstatus.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ManagedNetworkProvisionStatus struct { + SparkReady *bool `json:"sparkReady,omitempty"` + Status *ManagedNetworkStatus `json:"status,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_managednetworksettings.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_managednetworksettings.go new file mode 100644 index 00000000000..66518cc9f6b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_managednetworksettings.go @@ -0,0 +1,66 @@ +package workspaces + +import ( + "encoding/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 ManagedNetworkSettings struct { + FirewallPublicIPAddress *string `json:"firewallPublicIpAddress,omitempty"` + FirewallSku *FirewallSku `json:"firewallSku,omitempty"` + IsolationMode *IsolationMode `json:"isolationMode,omitempty"` + ManagedNetworkKind *ManagedNetworkKind `json:"managedNetworkKind,omitempty"` + NetworkId *string `json:"networkId,omitempty"` + OutboundRules *map[string]OutboundRule `json:"outboundRules,omitempty"` + Status *ManagedNetworkProvisionStatus `json:"status,omitempty"` +} + +var _ json.Unmarshaler = &ManagedNetworkSettings{} + +func (s *ManagedNetworkSettings) UnmarshalJSON(bytes []byte) error { + var decoded struct { + FirewallPublicIPAddress *string `json:"firewallPublicIpAddress,omitempty"` + FirewallSku *FirewallSku `json:"firewallSku,omitempty"` + IsolationMode *IsolationMode `json:"isolationMode,omitempty"` + ManagedNetworkKind *ManagedNetworkKind `json:"managedNetworkKind,omitempty"` + NetworkId *string `json:"networkId,omitempty"` + Status *ManagedNetworkProvisionStatus `json:"status,omitempty"` + } + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling: %+v", err) + } + + s.FirewallPublicIPAddress = decoded.FirewallPublicIPAddress + s.FirewallSku = decoded.FirewallSku + s.IsolationMode = decoded.IsolationMode + s.ManagedNetworkKind = decoded.ManagedNetworkKind + s.NetworkId = decoded.NetworkId + s.Status = decoded.Status + + var temp map[string]json.RawMessage + if err := json.Unmarshal(bytes, &temp); err != nil { + return fmt.Errorf("unmarshaling ManagedNetworkSettings into map[string]json.RawMessage: %+v", err) + } + + if v, ok := temp["outboundRules"]; ok { + var dictionaryTemp map[string]json.RawMessage + if err := json.Unmarshal(v, &dictionaryTemp); err != nil { + return fmt.Errorf("unmarshaling OutboundRules into dictionary map[string]json.RawMessage: %+v", err) + } + + output := make(map[string]OutboundRule) + for key, val := range dictionaryTemp { + impl, err := UnmarshalOutboundRuleImplementation(val) + if err != nil { + return fmt.Errorf("unmarshaling key %q field 'OutboundRules' for 'ManagedNetworkSettings': %+v", key, err) + } + output[key] = impl + } + s.OutboundRules = &output + } + + return nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_notebookaccesstokenresult.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_notebookaccesstokenresult.go new file mode 100644 index 00000000000..8e3b5c6600e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_notebookaccesstokenresult.go @@ -0,0 +1,15 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NotebookAccessTokenResult struct { + AccessToken *string `json:"accessToken,omitempty"` + ExpiresIn *int64 `json:"expiresIn,omitempty"` + HostName *string `json:"hostName,omitempty"` + NotebookResourceId *string `json:"notebookResourceId,omitempty"` + PublicDns *string `json:"publicDns,omitempty"` + RefreshToken *string `json:"refreshToken,omitempty"` + Scope *string `json:"scope,omitempty"` + TokenType *string `json:"tokenType,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_notebookpreparationerror.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_notebookpreparationerror.go new file mode 100644 index 00000000000..623ef1aa15e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_notebookpreparationerror.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NotebookPreparationError struct { + ErrorMessage *string `json:"errorMessage,omitempty"` + StatusCode *int64 `json:"statusCode,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_notebookresourceinfo.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_notebookresourceinfo.go new file mode 100644 index 00000000000..d3734f4291b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_notebookresourceinfo.go @@ -0,0 +1,10 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type NotebookResourceInfo struct { + Fqdn *string `json:"fqdn,omitempty"` + NotebookPreparationError *NotebookPreparationError `json:"notebookPreparationError,omitempty"` + ResourceId *string `json:"resourceId,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_outboundrule.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_outboundrule.go new file mode 100644 index 00000000000..a96ea9a74f3 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_outboundrule.go @@ -0,0 +1,95 @@ +package workspaces + +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 OutboundRule interface { + OutboundRule() BaseOutboundRuleImpl +} + +var _ OutboundRule = BaseOutboundRuleImpl{} + +type BaseOutboundRuleImpl struct { + Category *RuleCategory `json:"category,omitempty"` + ErrorInformation *string `json:"errorInformation,omitempty"` + ParentRuleNames *[]string `json:"parentRuleNames,omitempty"` + Status *RuleStatus `json:"status,omitempty"` + Type RuleType `json:"type"` +} + +func (s BaseOutboundRuleImpl) OutboundRule() BaseOutboundRuleImpl { + return s +} + +var _ OutboundRule = RawOutboundRuleImpl{} + +// RawOutboundRuleImpl 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 RawOutboundRuleImpl struct { + outboundRule BaseOutboundRuleImpl + Type string + Values map[string]interface{} +} + +func (s RawOutboundRuleImpl) OutboundRule() BaseOutboundRuleImpl { + return s.outboundRule +} + +func UnmarshalOutboundRuleImplementation(input []byte) (OutboundRule, 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 OutboundRule into map[string]interface: %+v", err) + } + + var value string + if v, ok := temp["type"]; ok { + value = fmt.Sprintf("%v", v) + } + + if strings.EqualFold(value, "FQDN") { + var out FqdnOutboundRule + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into FqdnOutboundRule: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "PrivateEndpoint") { + var out PrivateEndpointOutboundRule + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into PrivateEndpointOutboundRule: %+v", err) + } + return out, nil + } + + if strings.EqualFold(value, "ServiceTag") { + var out ServiceTagOutboundRule + if err := json.Unmarshal(input, &out); err != nil { + return nil, fmt.Errorf("unmarshaling into ServiceTagOutboundRule: %+v", err) + } + return out, nil + } + + var parent BaseOutboundRuleImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseOutboundRuleImpl: %+v", err) + } + + return RawOutboundRuleImpl{ + outboundRule: parent, + Type: value, + Values: temp, + }, nil + +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_password.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_password.go new file mode 100644 index 00000000000..4556b8a8c69 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_password.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Password struct { + Name *string `json:"name,omitempty"` + Value *string `json:"value,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_privateendpoint.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_privateendpoint.go new file mode 100644 index 00000000000..9f81ff8b836 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_privateendpoint.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpoint struct { + Id *string `json:"id,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_privateendpointconnection.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_privateendpointconnection.go new file mode 100644 index 00000000000..e838c643891 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_privateendpointconnection.go @@ -0,0 +1,21 @@ +package workspaces + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnection struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *PrivateEndpointConnectionProperties `json:"properties,omitempty"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_privateendpointconnectionproperties.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_privateendpointconnectionproperties.go new file mode 100644 index 00000000000..34f25f6a480 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_privateendpointconnectionproperties.go @@ -0,0 +1,10 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointConnectionProperties struct { + PrivateEndpoint *PrivateEndpoint `json:"privateEndpoint,omitempty"` + PrivateLinkServiceConnectionState PrivateLinkServiceConnectionState `json:"privateLinkServiceConnectionState"` + ProvisioningState *PrivateEndpointConnectionProvisioningState `json:"provisioningState,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_privateendpointdestination.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_privateendpointdestination.go new file mode 100644 index 00000000000..c25101797a2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_privateendpointdestination.go @@ -0,0 +1,11 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateEndpointDestination struct { + ServiceResourceId *string `json:"serviceResourceId,omitempty"` + SparkEnabled *bool `json:"sparkEnabled,omitempty"` + SparkStatus *RuleStatus `json:"sparkStatus,omitempty"` + SubresourceTarget *string `json:"subresourceTarget,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_privateendpointoutboundrule.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_privateendpointoutboundrule.go new file mode 100644 index 00000000000..ef1e13caa2d --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_privateendpointoutboundrule.go @@ -0,0 +1,58 @@ +package workspaces + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ OutboundRule = PrivateEndpointOutboundRule{} + +type PrivateEndpointOutboundRule struct { + Destination *PrivateEndpointDestination `json:"destination,omitempty"` + + // Fields inherited from OutboundRule + + Category *RuleCategory `json:"category,omitempty"` + ErrorInformation *string `json:"errorInformation,omitempty"` + ParentRuleNames *[]string `json:"parentRuleNames,omitempty"` + Status *RuleStatus `json:"status,omitempty"` + Type RuleType `json:"type"` +} + +func (s PrivateEndpointOutboundRule) OutboundRule() BaseOutboundRuleImpl { + return BaseOutboundRuleImpl{ + Category: s.Category, + ErrorInformation: s.ErrorInformation, + ParentRuleNames: s.ParentRuleNames, + Status: s.Status, + Type: s.Type, + } +} + +var _ json.Marshaler = PrivateEndpointOutboundRule{} + +func (s PrivateEndpointOutboundRule) MarshalJSON() ([]byte, error) { + type wrapper PrivateEndpointOutboundRule + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling PrivateEndpointOutboundRule: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling PrivateEndpointOutboundRule: %+v", err) + } + + decoded["type"] = "PrivateEndpoint" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling PrivateEndpointOutboundRule: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_privatelinkserviceconnectionstate.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_privatelinkserviceconnectionstate.go new file mode 100644 index 00000000000..1bca40e3dfd --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_privatelinkserviceconnectionstate.go @@ -0,0 +1,10 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type PrivateLinkServiceConnectionState struct { + ActionsRequired *string `json:"actionsRequired,omitempty"` + Description *string `json:"description,omitempty"` + Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_registrylistcredentialsresult.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_registrylistcredentialsresult.go new file mode 100644 index 00000000000..e4f50cf1aff --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_registrylistcredentialsresult.go @@ -0,0 +1,10 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type RegistryListCredentialsResult struct { + Location *string `json:"location,omitempty"` + Passwords *[]Password `json:"passwords,omitempty"` + Username *string `json:"username,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_serverlesscomputesettings.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_serverlesscomputesettings.go new file mode 100644 index 00000000000..2143119370a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_serverlesscomputesettings.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServerlessComputeSettings struct { + ServerlessComputeCustomSubnet *string `json:"serverlessComputeCustomSubnet,omitempty"` + ServerlessComputeNoPublicIP *bool `json:"serverlessComputeNoPublicIP,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_servicemanagedresourcessettings.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_servicemanagedresourcessettings.go new file mode 100644 index 00000000000..0599d10f00a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_servicemanagedresourcessettings.go @@ -0,0 +1,8 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceManagedResourcesSettings struct { + CosmosDb *CosmosDbSettings `json:"cosmosDb,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_servicetagdestination.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_servicetagdestination.go new file mode 100644 index 00000000000..65882c5a53b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_servicetagdestination.go @@ -0,0 +1,12 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type ServiceTagDestination struct { + Action *RuleAction `json:"action,omitempty"` + AddressPrefixes *[]string `json:"addressPrefixes,omitempty"` + PortRanges *string `json:"portRanges,omitempty"` + Protocol *string `json:"protocol,omitempty"` + ServiceTag *string `json:"serviceTag,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_servicetagoutboundrule.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_servicetagoutboundrule.go new file mode 100644 index 00000000000..626e4737456 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_servicetagoutboundrule.go @@ -0,0 +1,58 @@ +package workspaces + +import ( + "encoding/json" + "fmt" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +var _ OutboundRule = ServiceTagOutboundRule{} + +type ServiceTagOutboundRule struct { + Destination *ServiceTagDestination `json:"destination,omitempty"` + + // Fields inherited from OutboundRule + + Category *RuleCategory `json:"category,omitempty"` + ErrorInformation *string `json:"errorInformation,omitempty"` + ParentRuleNames *[]string `json:"parentRuleNames,omitempty"` + Status *RuleStatus `json:"status,omitempty"` + Type RuleType `json:"type"` +} + +func (s ServiceTagOutboundRule) OutboundRule() BaseOutboundRuleImpl { + return BaseOutboundRuleImpl{ + Category: s.Category, + ErrorInformation: s.ErrorInformation, + ParentRuleNames: s.ParentRuleNames, + Status: s.Status, + Type: s.Type, + } +} + +var _ json.Marshaler = ServiceTagOutboundRule{} + +func (s ServiceTagOutboundRule) MarshalJSON() ([]byte, error) { + type wrapper ServiceTagOutboundRule + wrapped := wrapper(s) + encoded, err := json.Marshal(wrapped) + if err != nil { + return nil, fmt.Errorf("marshaling ServiceTagOutboundRule: %+v", err) + } + + var decoded map[string]interface{} + if err = json.Unmarshal(encoded, &decoded); err != nil { + return nil, fmt.Errorf("unmarshaling ServiceTagOutboundRule: %+v", err) + } + + decoded["type"] = "ServiceTag" + + encoded, err = json.Marshal(decoded) + if err != nil { + return nil, fmt.Errorf("re-marshaling ServiceTagOutboundRule: %+v", err) + } + + return encoded, nil +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_sharedprivatelinkresource.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_sharedprivatelinkresource.go new file mode 100644 index 00000000000..3fea7381a66 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_sharedprivatelinkresource.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedPrivateLinkResource struct { + Name *string `json:"name,omitempty"` + Properties *SharedPrivateLinkResourceProperty `json:"properties,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_sharedprivatelinkresourceproperty.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_sharedprivatelinkresourceproperty.go new file mode 100644 index 00000000000..cfa93bf77b2 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_sharedprivatelinkresourceproperty.go @@ -0,0 +1,11 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type SharedPrivateLinkResourceProperty struct { + GroupId *string `json:"groupId,omitempty"` + PrivateLinkResourceId *string `json:"privateLinkResourceId,omitempty"` + RequestMessage *string `json:"requestMessage,omitempty"` + Status *PrivateEndpointServiceConnectionStatus `json:"status,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_sku.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_sku.go new file mode 100644 index 00000000000..0463a27a38e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_sku.go @@ -0,0 +1,12 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Sku struct { + Capacity *int64 `json:"capacity,omitempty"` + Family *string `json:"family,omitempty"` + Name string `json:"name"` + Size *string `json:"size,omitempty"` + Tier *SkuTier `json:"tier,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_workspace.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_workspace.go new file mode 100644 index 00000000000..b2a389de81a --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_workspace.go @@ -0,0 +1,22 @@ +package workspaces + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" + "github.com/hashicorp/go-azure-helpers/resourcemanager/systemdata" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type Workspace struct { + Id *string `json:"id,omitempty"` + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Kind *string `json:"kind,omitempty"` + Location *string `json:"location,omitempty"` + Name *string `json:"name,omitempty"` + Properties *WorkspaceProperties `json:"properties,omitempty"` + Sku *Sku `json:"sku,omitempty"` + SystemData *systemdata.SystemData `json:"systemData,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` + Type *string `json:"type,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_workspacehubconfig.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_workspacehubconfig.go new file mode 100644 index 00000000000..54197380d7b --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_workspacehubconfig.go @@ -0,0 +1,9 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceHubConfig struct { + AdditionalWorkspaceStorageAccounts *[]string `json:"additionalWorkspaceStorageAccounts,omitempty"` + DefaultWorkspaceResourceGroup *string `json:"defaultWorkspaceResourceGroup,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_workspaceproperties.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_workspaceproperties.go new file mode 100644 index 00000000000..70a1204bf20 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_workspaceproperties.go @@ -0,0 +1,39 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceProperties struct { + AllowPublicAccessWhenBehindVnet *bool `json:"allowPublicAccessWhenBehindVnet,omitempty"` + ApplicationInsights *string `json:"applicationInsights,omitempty"` + AssociatedWorkspaces *[]string `json:"associatedWorkspaces,omitempty"` + ContainerRegistry *string `json:"containerRegistry,omitempty"` + Description *string `json:"description,omitempty"` + DiscoveryURL *string `json:"discoveryUrl,omitempty"` + EnableDataIsolation *bool `json:"enableDataIsolation,omitempty"` + Encryption *EncryptionProperty `json:"encryption,omitempty"` + FeatureStoreSettings *FeatureStoreSettings `json:"featureStoreSettings,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + HbiWorkspace *bool `json:"hbiWorkspace,omitempty"` + HubResourceId *string `json:"hubResourceId,omitempty"` + ImageBuildCompute *string `json:"imageBuildCompute,omitempty"` + KeyVault *string `json:"keyVault,omitempty"` + ManagedNetwork *ManagedNetworkSettings `json:"managedNetwork,omitempty"` + MlFlowTrackingUri *string `json:"mlFlowTrackingUri,omitempty"` + NotebookInfo *NotebookResourceInfo `json:"notebookInfo,omitempty"` + PrimaryUserAssignedIdentity *string `json:"primaryUserAssignedIdentity,omitempty"` + PrivateEndpointConnections *[]PrivateEndpointConnection `json:"privateEndpointConnections,omitempty"` + PrivateLinkCount *int64 `json:"privateLinkCount,omitempty"` + ProvisioningState *ProvisioningState `json:"provisioningState,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + ServerlessComputeSettings *ServerlessComputeSettings `json:"serverlessComputeSettings,omitempty"` + ServiceManagedResourcesSettings *ServiceManagedResourcesSettings `json:"serviceManagedResourcesSettings,omitempty"` + ServiceProvisionedResourceGroup *string `json:"serviceProvisionedResourceGroup,omitempty"` + SharedPrivateLinkResources *[]SharedPrivateLinkResource `json:"sharedPrivateLinkResources,omitempty"` + StorageAccount *string `json:"storageAccount,omitempty"` + StorageHnsEnabled *bool `json:"storageHnsEnabled,omitempty"` + TenantId *string `json:"tenantId,omitempty"` + V1LegacyMode *bool `json:"v1LegacyMode,omitempty"` + WorkspaceHubConfig *WorkspaceHubConfig `json:"workspaceHubConfig,omitempty"` + WorkspaceId *string `json:"workspaceId,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_workspacepropertiesupdateparameters.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_workspacepropertiesupdateparameters.go new file mode 100644 index 00000000000..75dc6dd9772 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_workspacepropertiesupdateparameters.go @@ -0,0 +1,21 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspacePropertiesUpdateParameters struct { + ApplicationInsights *string `json:"applicationInsights,omitempty"` + ContainerRegistry *string `json:"containerRegistry,omitempty"` + Description *string `json:"description,omitempty"` + EnableDataIsolation *bool `json:"enableDataIsolation,omitempty"` + Encryption *EncryptionUpdateProperties `json:"encryption,omitempty"` + FeatureStoreSettings *FeatureStoreSettings `json:"featureStoreSettings,omitempty"` + FriendlyName *string `json:"friendlyName,omitempty"` + ImageBuildCompute *string `json:"imageBuildCompute,omitempty"` + ManagedNetwork *ManagedNetworkSettings `json:"managedNetwork,omitempty"` + PrimaryUserAssignedIdentity *string `json:"primaryUserAssignedIdentity,omitempty"` + PublicNetworkAccess *PublicNetworkAccess `json:"publicNetworkAccess,omitempty"` + ServerlessComputeSettings *ServerlessComputeSettings `json:"serverlessComputeSettings,omitempty"` + ServiceManagedResourcesSettings *ServiceManagedResourcesSettings `json:"serviceManagedResourcesSettings,omitempty"` + V1LegacyMode *bool `json:"v1LegacyMode,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/model_workspaceupdateparameters.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_workspaceupdateparameters.go new file mode 100644 index 00000000000..0322a7064f9 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/model_workspaceupdateparameters.go @@ -0,0 +1,15 @@ +package workspaces + +import ( + "github.com/hashicorp/go-azure-helpers/resourcemanager/identity" +) + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type WorkspaceUpdateParameters struct { + Identity *identity.LegacySystemAndUserAssignedMap `json:"identity,omitempty"` + Properties *WorkspacePropertiesUpdateParameters `json:"properties,omitempty"` + Sku *Sku `json:"sku,omitempty"` + Tags *map[string]string `json:"tags,omitempty"` +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/predicates.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/predicates.go new file mode 100644 index 00000000000..3890494581e --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/predicates.go @@ -0,0 +1,60 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +type AmlUserFeatureOperationPredicate struct { + Description *string + DisplayName *string + Id *string +} + +func (p AmlUserFeatureOperationPredicate) Matches(input AmlUserFeature) bool { + + if p.Description != nil && (input.Description == nil || *p.Description != *input.Description) { + return false + } + + if p.DisplayName != nil && (input.DisplayName == nil || *p.DisplayName != *input.DisplayName) { + return false + } + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + return true +} + +type WorkspaceOperationPredicate struct { + Id *string + Kind *string + Location *string + Name *string + Type *string +} + +func (p WorkspaceOperationPredicate) Matches(input Workspace) bool { + + if p.Id != nil && (input.Id == nil || *p.Id != *input.Id) { + return false + } + + if p.Kind != nil && (input.Kind == nil || *p.Kind != *input.Kind) { + return false + } + + if p.Location != nil && (input.Location == nil || *p.Location != *input.Location) { + return false + } + + if p.Name != nil && (input.Name == nil || *p.Name != *input.Name) { + return false + } + + if p.Type != nil && (input.Type == nil || *p.Type != *input.Type) { + return false + } + + return true +} diff --git a/resource-manager/machinelearningservices/2025-04-01/workspaces/version.go b/resource-manager/machinelearningservices/2025-04-01/workspaces/version.go new file mode 100644 index 00000000000..9af72f25d21 --- /dev/null +++ b/resource-manager/machinelearningservices/2025-04-01/workspaces/version.go @@ -0,0 +1,10 @@ +package workspaces + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2025-04-01" + +func userAgent() string { + return "hashicorp/go-azure-sdk/workspaces/2025-04-01" +} 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" +}