From d2d1252fabb67885353e591b9bf3ddaf1d9ea6f1 Mon Sep 17 00:00:00 2001 From: Xu Zhang Date: Wed, 28 Aug 2024 13:36:36 +0800 Subject: [PATCH 1/9] add mlw outboundrule client --- .../services/machinelearning/client/client.go | 9 + .../2024-04-01/managednetwork/README.md | 99 ++++++++ .../2024-04-01/managednetwork/client.go | 26 ++ .../2024-04-01/managednetwork/constants.go | 224 ++++++++++++++++++ .../managednetwork/id_outboundrule.go | 139 +++++++++++ .../2024-04-01/managednetwork/id_workspace.go | 130 ++++++++++ ...ethod_provisionsprovisionmanagednetwork.go | 75 ++++++ .../method_settingsrulecreateorupdate.go | 75 ++++++ .../method_settingsruledelete.go | 71 ++++++ .../managednetwork/method_settingsruleget.go | 54 +++++ .../managednetwork/method_settingsrulelist.go | 105 ++++++++ .../managednetwork/model_fqdnoutboundrule.go | 43 ++++ .../model_managednetworkprovisionoptions.go | 8 + .../model_managednetworkprovisionstatus.go | 9 + .../managednetwork/model_outboundrule.go | 69 ++++++ .../model_outboundrulebasicresource.go | 48 ++++ .../model_privateendpointdestination.go | 11 + .../model_privateendpointoutboundrule.go | 43 ++++ .../model_servicetagdestination.go | 12 + .../model_servicetagoutboundrule.go | 43 ++++ .../2024-04-01/managednetwork/predicates.go | 27 +++ .../2024-04-01/managednetwork/version.go | 12 + .../resource/testing_new_import_state.go | 3 + vendor/modules.txt | 1 + 24 files changed, 1336 insertions(+) create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/README.md create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/client.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/constants.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/id_outboundrule.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/id_workspace.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/method_provisionsprovisionmanagednetwork.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/method_settingsrulecreateorupdate.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/method_settingsruledelete.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/method_settingsruleget.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/method_settingsrulelist.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_fqdnoutboundrule.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_managednetworkprovisionoptions.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_managednetworkprovisionstatus.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_outboundrule.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_outboundrulebasicresource.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_privateendpointdestination.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_privateendpointoutboundrule.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_servicetagdestination.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_servicetagoutboundrule.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/predicates.go create mode 100644 vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/version.go diff --git a/internal/services/machinelearning/client/client.go b/internal/services/machinelearning/client/client.go index 32eeed008b47..a2624c2ef575 100644 --- a/internal/services/machinelearning/client/client.go +++ b/internal/services/machinelearning/client/client.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/datastore" "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/machinelearningcomputes" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork" "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/workspaces" "github.com/hashicorp/terraform-provider-azurerm/internal/common" ) @@ -16,6 +17,7 @@ type Client struct { Datastore *datastore.DatastoreClient MachineLearningComputes *machinelearningcomputes.MachineLearningComputesClient Workspaces *workspaces.WorkspacesClient + ManagedNetwork *managednetwork.ManagedNetworkClient } func NewClient(o *common.ClientOptions) (*Client, error) { @@ -37,9 +39,16 @@ func NewClient(o *common.ClientOptions) (*Client, error) { } o.Configure(computesClient.Client, o.Authorizers.ResourceManager) + managedNetworkClient, err := managednetwork.NewManagedNetworkClientWithBaseURI(o.Environment.ResourceManager) + if err != nil { + return nil, fmt.Errorf("building MachineLearningComputes client: %+v", err) + } + o.Configure(computesClient.Client, o.Authorizers.ResourceManager) + return &Client{ MachineLearningComputes: computesClient, Datastore: datastoreClient, Workspaces: workspacesClient, + ManagedNetwork: managedNetworkClient, }, nil } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/README.md new file mode 100644 index 000000000000..6ab495a888f8 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/README.md @@ -0,0 +1,99 @@ + +## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork` Documentation + +The `managednetwork` SDK allows for interaction with the Azure Resource Manager Service `machinelearningservices` (API Version `2024-04-01`). + +This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). + +### Import Path + +```go +import "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-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", "workspaceValue") + +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", "workspaceValue", "outboundRuleValue") + +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", "workspaceValue", "outboundRuleValue") + +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", "workspaceValue", "outboundRuleValue") + +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", "workspaceValue") + +// 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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/client.go new file mode 100644 index 000000000000..6313700a6ea5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-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.NewResourceManagerClient(sdkApi, "managednetwork", defaultApiVersion) + if err != nil { + return nil, fmt.Errorf("instantiating ManagedNetworkClient: %+v", err) + } + + return &ManagedNetworkClient{ + Client: client, + }, nil +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/constants.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/constants.go new file mode 100644 index 000000000000..e19e9f0a600f --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/constants.go @@ -0,0 +1,224 @@ +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" + RuleStatusInactive RuleStatus = "Inactive" +) + +func PossibleValuesForRuleStatus() []string { + return []string{ + string(RuleStatusActive), + string(RuleStatusInactive), + } +} + +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, + "inactive": RuleStatusInactive, + } + 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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/id_outboundrule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/id_outboundrule.go new file mode 100644 index 000000000000..e8f379567d6d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-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", "workspaceValue"), + resourceids.StaticSegment("staticOutboundRules", "outboundRules", "outboundRules"), + resourceids.UserSpecifiedSegment("outboundRuleName", "outboundRuleValue"), + } +} + +// 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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/id_workspace.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/id_workspace.go new file mode 100644 index 000000000000..cd60cc5e74a5 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-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", "workspaceValue"), + } +} + +// 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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/method_provisionsprovisionmanagednetwork.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/method_provisionsprovisionmanagednetwork.go new file mode 100644 index 000000000000..e35f68f85d22 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/method_settingsrulecreateorupdate.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/method_settingsrulecreateorupdate.go new file mode 100644 index 000000000000..9e4eec71434a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/method_settingsruledelete.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/method_settingsruledelete.go new file mode 100644 index 000000000000..6306e801dd7d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/method_settingsruleget.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/method_settingsruleget.go new file mode 100644 index 000000000000..87f7ac2e3447 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/method_settingsruleget.go @@ -0,0 +1,54 @@ +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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/method_settingsrulelist.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/method_settingsrulelist.go new file mode 100644 index 000000000000..b73fd89a69d2 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_fqdnoutboundrule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_fqdnoutboundrule.go new file mode 100644 index 000000000000..70921895572b --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_fqdnoutboundrule.go @@ -0,0 +1,43 @@ +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"` + Status *RuleStatus `json:"status,omitempty"` +} + +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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_managednetworkprovisionoptions.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_managednetworkprovisionoptions.go new file mode 100644 index 000000000000..4d2c03673057 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_managednetworkprovisionstatus.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_managednetworkprovisionstatus.go new file mode 100644 index 000000000000..3010b961a344 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_outboundrule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_outboundrule.go new file mode 100644 index 000000000000..8e5529b02dce --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_outboundrule.go @@ -0,0 +1,69 @@ +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 { +} + +// 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 { + Type string + Values map[string]interface{} +} + +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) + } + + value, ok := temp["type"].(string) + if !ok { + return nil, nil + } + + 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 + } + + out := RawOutboundRuleImpl{ + Type: value, + Values: temp, + } + return out, nil + +} diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_outboundrulebasicresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_outboundrulebasicresource.go new file mode 100644 index 000000000000..8c333ed73f1c --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_outboundrulebasicresource.go @@ -0,0 +1,48 @@ +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 { + type alias OutboundRuleBasicResource + var decoded alias + if err := json.Unmarshal(bytes, &decoded); err != nil { + return fmt.Errorf("unmarshaling into OutboundRuleBasicResource: %+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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_privateendpointdestination.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_privateendpointdestination.go new file mode 100644 index 000000000000..30060d85562a --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_privateendpointoutboundrule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_privateendpointoutboundrule.go new file mode 100644 index 000000000000..da6f88ed30cf --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_privateendpointoutboundrule.go @@ -0,0 +1,43 @@ +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"` + Status *RuleStatus `json:"status,omitempty"` +} + +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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_servicetagdestination.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_servicetagdestination.go new file mode 100644 index 000000000000..efbbd4e7c8de --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_servicetagoutboundrule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_servicetagoutboundrule.go new file mode 100644 index 000000000000..2bb23ca8815d --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_servicetagoutboundrule.go @@ -0,0 +1,43 @@ +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"` + Status *RuleStatus `json:"status,omitempty"` +} + +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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/predicates.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/predicates.go new file mode 100644 index 000000000000..960a0afdff58 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/version.go new file mode 100644 index 000000000000..61486bdd2250 --- /dev/null +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/version.go @@ -0,0 +1,12 @@ +package managednetwork + +import "fmt" + +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See NOTICE.txt in the project root for license information. + +const defaultApiVersion = "2024-04-01" + +func userAgent() string { + return fmt.Sprintf("hashicorp/go-azure-sdk/managednetwork/%s", defaultApiVersion) +} diff --git a/vendor/github.com/hashicorp/terraform-plugin-testing/helper/resource/testing_new_import_state.go b/vendor/github.com/hashicorp/terraform-plugin-testing/helper/resource/testing_new_import_state.go index 7dbc0b800b4d..e0f8440af259 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-testing/helper/resource/testing_new_import_state.go +++ b/vendor/github.com/hashicorp/terraform-plugin-testing/helper/resource/testing_new_import_state.go @@ -264,13 +264,16 @@ func testStepNewImportState(ctx context.Context, t testing.T, helper *plugintest // Remove fields we're ignoring for _, v := range step.ImportStateVerifyIgnore { + fmt.Printf("ImportStateVerifyIgnore name: %s", v) for k := range actual { if strings.HasPrefix(k, v) { + fmt.Printf("ImportStateVerifyIgnore name: %s deleted in actual", v) delete(actual, k) } } for k := range expected { if strings.HasPrefix(k, v) { + fmt.Printf("ImportStateVerifyIgnore name: %s deleted in actual", v) delete(expected, k) } } diff --git a/vendor/modules.txt b/vendor/modules.txt index 9526199bdb42..740ae3011b0c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -625,6 +625,7 @@ github.com/hashicorp/go-azure-sdk/resource-manager/logz/2020-10-01/subaccount github.com/hashicorp/go-azure-sdk/resource-manager/logz/2020-10-01/tagrules github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/datastore github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/machinelearningcomputes +github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/workspaces github.com/hashicorp/go-azure-sdk/resource-manager/maintenance/2023-04-01/configurationassignments github.com/hashicorp/go-azure-sdk/resource-manager/maintenance/2023-04-01/maintenanceconfigurations From 638e753dce0e34e8f17a79920e9962d123e999a5 Mon Sep 17 00:00:00 2001 From: Xu Zhang Date: Fri, 13 Sep 2024 17:08:14 +0800 Subject: [PATCH 2/9] add support for machine learning workspace network outbound rule FQDN --- .../services/machinelearning/client/client.go | 4 +- ...ace_network_outbound_rule_fqdn_resource.go | 231 +++++++++++++++++ ...etwork_outbound_rule_fqdn_resource_test.go | 240 ++++++++++++++++++ .../services/machinelearning/registration.go | 1 + ...ce_network_outboundrule_fqdn.html.markdown | 106 ++++++++ 5 files changed, 580 insertions(+), 2 deletions(-) create mode 100644 internal/services/machinelearning/machine_learning_workspace_network_outbound_rule_fqdn_resource.go create mode 100644 internal/services/machinelearning/machine_learning_workspace_network_outbound_rule_fqdn_resource_test.go create mode 100644 website/docs/r/machine_learning_workspace_network_outboundrule_fqdn.html.markdown diff --git a/internal/services/machinelearning/client/client.go b/internal/services/machinelearning/client/client.go index a2624c2ef575..4d6385828281 100644 --- a/internal/services/machinelearning/client/client.go +++ b/internal/services/machinelearning/client/client.go @@ -41,9 +41,9 @@ func NewClient(o *common.ClientOptions) (*Client, error) { managedNetworkClient, err := managednetwork.NewManagedNetworkClientWithBaseURI(o.Environment.ResourceManager) if err != nil { - return nil, fmt.Errorf("building MachineLearningComputes client: %+v", err) + return nil, fmt.Errorf("building MachineLearningNetwork client: %+v", err) } - o.Configure(computesClient.Client, o.Authorizers.ResourceManager) + o.Configure(managedNetworkClient.Client, o.Authorizers.ResourceManager) return &Client{ MachineLearningComputes: computesClient, diff --git a/internal/services/machinelearning/machine_learning_workspace_network_outbound_rule_fqdn_resource.go b/internal/services/machinelearning/machine_learning_workspace_network_outbound_rule_fqdn_resource.go new file mode 100644 index 000000000000..19075d892207 --- /dev/null +++ b/internal/services/machinelearning/machine_learning_workspace_network_outbound_rule_fqdn_resource.go @@ -0,0 +1,231 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package machinelearning + +import ( + "context" + "fmt" + "time" + + "github.com/hashicorp/go-azure-helpers/lang/pointer" + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/workspaces" + "github.com/hashicorp/terraform-provider-azurerm/helpers/tf" + "github.com/hashicorp/terraform-provider-azurerm/internal/sdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/validation" +) + +var _ sdk.ResourceWithUpdate = WorkspaceNetworkOutboundRuleFqdn{} + +type machineLearningWorkspaceOutboundRuleFqdnModel struct { + Name string `tfschema:"name"` + WorkspaceId string `tfschema:"workspace_id"` + Destination string `tfschema:"destination"` +} + +type WorkspaceNetworkOutboundRuleFqdn struct{} + +var _ sdk.Resource = WorkspaceNetworkOutboundRuleFqdn{} + +func (r WorkspaceNetworkOutboundRuleFqdn) ResourceType() string { + return "azurerm_machine_learning_workspace_network_outbound_rule_fqdn" +} + +func (r WorkspaceNetworkOutboundRuleFqdn) ModelObject() interface{} { + return &machineLearningWorkspaceOutboundRuleFqdnModel{} +} + +func (r WorkspaceNetworkOutboundRuleFqdn) IDValidationFunc() pluginsdk.SchemaValidateFunc { + return managednetwork.ValidateOutboundRuleID +} + +func (r WorkspaceNetworkOutboundRuleFqdn) Arguments() map[string]*pluginsdk.Schema { + arguments := map[string]*pluginsdk.Schema{ + "name": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + + "workspace_id": { + Type: pluginsdk.TypeString, + Required: true, + ForceNew: true, + ValidateFunc: managednetwork.ValidateWorkspaceID, + }, + + "destination": { + Type: pluginsdk.TypeString, + Required: true, + ValidateFunc: validation.StringIsNotEmpty, + }, + } + return arguments +} + +func (r WorkspaceNetworkOutboundRuleFqdn) Attributes() map[string]*pluginsdk.Schema { + return map[string]*pluginsdk.Schema{} +} + +func (r WorkspaceNetworkOutboundRuleFqdn) Create() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + var model machineLearningWorkspaceOutboundRuleFqdnModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + client := metadata.Client.MachineLearning.ManagedNetwork + subscriptionId := metadata.Client.Account.SubscriptionId + + workspaceId, err := managednetwork.ParseWorkspaceID(model.WorkspaceId) + if err != nil { + return err + } + id := managednetwork.NewOutboundRuleID(subscriptionId, workspaceId.ResourceGroupName, workspaceId.WorkspaceName, model.Name) + existing, err := client.SettingsRuleGet(ctx, id) + if err != nil { + if !response.WasNotFound(existing.HttpResponse) { + return fmt.Errorf("checking for presence of existing %s: %+v", id, err) + } + } + if !response.WasNotFound(existing.HttpResponse) { + return tf.ImportAsExistsError("azurerm_machine_learning_workspace_network_outbound_rule_fqdn", id.ID()) + } + + outboundRule := managednetwork.OutboundRuleBasicResource{ + Name: pointer.To(model.Name), + Type: pointer.To(string(managednetwork.RuleTypeFQDN)), + Properties: managednetwork.FqdnOutboundRule{ + Category: pointer.To(managednetwork.RuleCategoryUserDefined), + Destination: &model.Destination, + }, + } + + if err = client.SettingsRuleCreateOrUpdateThenPoll(ctx, id, outboundRule); err != nil { + return fmt.Errorf("creating %s: %+v", id, err) + } + + metadata.SetID(id) + return nil + }, + } +} + +func (r WorkspaceNetworkOutboundRuleFqdn) Update() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + var model machineLearningWorkspaceOutboundRuleFqdnModel + if err := metadata.Decode(&model); err != nil { + return fmt.Errorf("decoding: %+v", err) + } + + client := metadata.Client.MachineLearning.ManagedNetwork + id, err := managednetwork.ParseOutboundRuleID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + existing, err := client.SettingsRuleGet(ctx, *id) + if err != nil { + return fmt.Errorf("retrieving %s: %+v", id, err) + } + + if existing.Model == nil { + return fmt.Errorf("retrieving %s: `model` was nil", id) + } + + if existing.Model.Properties == nil { + return fmt.Errorf("retrieving %s: `properties` was nil", id) + } + + payload := existing.Model + + if metadata.ResourceData.HasChange("destination") { + payload.Properties = managednetwork.FqdnOutboundRule{ + Destination: &model.Destination, + } + } + + if err = client.SettingsRuleCreateOrUpdateThenPoll(ctx, *id, *payload); err != nil { + return fmt.Errorf("updating %s: %+v", id, err) + } + return nil + }, + } +} + +func (r WorkspaceNetworkOutboundRuleFqdn) Read() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 5 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.MachineLearning.ManagedNetwork + + id, err := managednetwork.ParseOutboundRuleID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + resp, err := client.SettingsRuleGet(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return metadata.MarkAsGone(id) + } + + return fmt.Errorf("retrieving %s: %+v", *id, err) + } + + model := resp.Model + if model == nil { + return fmt.Errorf("retrieving %s: model was nil", id) + } + + state := machineLearningWorkspaceOutboundRuleFqdnModel{ + Name: id.OutboundRuleName, + } + + if props := model.Properties; props != nil { + if prop, ok := props.(managednetwork.FqdnOutboundRule); ok { + if prop.Destination != nil { + state.Destination = *prop.Destination + } + } + } + + state.WorkspaceId = workspaces.NewWorkspaceID(metadata.Client.Account.SubscriptionId, id.ResourceGroupName, id.WorkspaceName).ID() + + return metadata.Encode(&state) + }, + } +} + +func (r WorkspaceNetworkOutboundRuleFqdn) Delete() sdk.ResourceFunc { + return sdk.ResourceFunc{ + Timeout: 30 * time.Minute, + Func: func(ctx context.Context, metadata sdk.ResourceMetaData) error { + client := metadata.Client.MachineLearning.ManagedNetwork + + id, err := managednetwork.ParseOutboundRuleID(metadata.ResourceData.Id()) + if err != nil { + return err + } + + future, err := client.SettingsRuleDelete(ctx, *id) + if err != nil { + return fmt.Errorf("deleting Machine Learning Workspace FQDN Network Outbound Rule %q (Resource Group %q, Workspace %q): %+v", id.OutboundRuleName, id.ResourceGroupName, id.WorkspaceName, err) + } + + if err = future.Poller.PollUntilDone(ctx); err != nil { + return fmt.Errorf("waiting for deletion of Machine Learning Workspace FQDN Network Outbound Rule %q (Resource Group %q, Workspace %q): %+v", id.OutboundRuleName, id.ResourceGroupName, id.WorkspaceName, err) + } + + return nil + }, + } +} diff --git a/internal/services/machinelearning/machine_learning_workspace_network_outbound_rule_fqdn_resource_test.go b/internal/services/machinelearning/machine_learning_workspace_network_outbound_rule_fqdn_resource_test.go new file mode 100644 index 000000000000..a16c5edec3f1 --- /dev/null +++ b/internal/services/machinelearning/machine_learning_workspace_network_outbound_rule_fqdn_resource_test.go @@ -0,0 +1,240 @@ +// Copyright (c) HashiCorp, Inc. +// SPDX-License-Identifier: MPL-2.0 + +package machinelearning_test + +import ( + "context" + "fmt" + "testing" + + "github.com/hashicorp/go-azure-helpers/lang/response" + "github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance" + "github.com/hashicorp/terraform-provider-azurerm/internal/acceptance/check" + "github.com/hashicorp/terraform-provider-azurerm/internal/clients" + "github.com/hashicorp/terraform-provider-azurerm/internal/tf/pluginsdk" + "github.com/hashicorp/terraform-provider-azurerm/utils" +) + +type WorkspaceNetworkOutboundRuleFqdnResource struct{} + +func TestAccMachineLearningWorkspaceNetworkOutboundRuleFqdn_basic(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_machine_learning_workspace_network_outbound_rule_fqdn", "test") + r := WorkspaceNetworkOutboundRuleFqdnResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("destination").Exists(), + ), + }, + data.ImportStep(), + }) +} + +func TestAccMachineLearningWorkspaceNetworkOutboundRuleFqdn_update(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_machine_learning_workspace_network_outbound_rule_fqdn", "test") + r := WorkspaceNetworkOutboundRuleFqdnResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("destination").Exists(), + ), + }, + data.ImportStep(), + { + Config: r.update(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("destination").HasValue("destinationupdate"), + ), + }, + data.ImportStep(), + }) +} + +func TestAccMachineLearningWorkspaceOutboundFqdn_requiresImport(t *testing.T) { + data := acceptance.BuildTestData(t, "azurerm_machine_learning_workspace_network_outbound_rule_fqdn", "test") + r := WorkspaceNetworkOutboundRuleFqdnResource{} + + data.ResourceTest(t, r, []acceptance.TestStep{ + { + Config: r.basic(data), + Check: acceptance.ComposeTestCheckFunc( + check.That(data.ResourceName).ExistsInAzure(r), + check.That(data.ResourceName).Key("destination").Exists(), + ), + }, + data.RequiresImportErrorStep(r.requiresImport), + }) +} + +func (r WorkspaceNetworkOutboundRuleFqdnResource) Exists(ctx context.Context, client *clients.Client, state *pluginsdk.InstanceState) (*bool, error) { + maangedNetworkClient := client.MachineLearning.ManagedNetwork + id, err := managednetwork.ParseOutboundRuleID(state.ID) + if err != nil { + return nil, err + } + + resp, err := maangedNetworkClient.SettingsRuleGet(ctx, *id) + if err != nil { + if response.WasNotFound(resp.HttpResponse) { + return utils.Bool(false), nil + } + return nil, fmt.Errorf("retrieving Machine Learning Workspace Outbound Rule FQDN %q: %+v", state.ID, err) + } + + return utils.Bool(resp.Model.Properties != nil), nil +} + +func (r WorkspaceNetworkOutboundRuleFqdnResource) template(data acceptance.TestData) string { + return fmt.Sprintf(` +data "azurerm_client_config" "current" {} + +resource "azurerm_resource_group" "test" { + name = "acctestRG-ml-%[1]d" + location = "%[2]s" +} + +resource "azurerm_application_insights" "test" { + name = "acctestai-%[1]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + application_type = "web" +} + +resource "azurerm_key_vault" "test" { + name = "acctestvault%[3]s" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + tenant_id = data.azurerm_client_config.current.tenant_id + sku_name = "standard" + purge_protection_enabled = true +} + +resource "azurerm_key_vault_access_policy" "test" { + key_vault_id = azurerm_key_vault.test.id + tenant_id = data.azurerm_client_config.current.tenant_id + object_id = data.azurerm_client_config.current.object_id + + key_permissions = [ + "Create", + "Get", + "Delete", + "Purge", + "GetRotationPolicy", + ] +} + +resource "azurerm_storage_account" "test" { + name = "acctestsa%[4]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + account_tier = "Standard" + account_replication_type = "LRS" +} +`, data.RandomInteger, data.Locations.Primary, data.RandomString, data.RandomIntOfLength(10)) +} + +func (r WorkspaceNetworkOutboundRuleFqdnResource) basic(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` +provider "azurerm" { + features { + key_vault { + purge_soft_delete_on_destroy = false + purge_soft_deleted_keys_on_destroy = false + } + resource_group { + prevent_deletion_if_contains_resources = false + } + } +} + +%[1]s + +resource "azurerm_machine_learning_workspace" "test" { + name = "acctest-MLW-%[2]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + application_insights_id = azurerm_application_insights.test.id + key_vault_id = azurerm_key_vault.test.id + storage_account_id = azurerm_storage_account.test.id + + managed_network { + isolation_mode = "AllowOnlyApprovedOutbound" + } + + identity { + type = "SystemAssigned" + } +} + +resource "azurerm_machine_learning_workspace_network_outbound_rule_fqdn" "test" { + name = "acctest-MLW-outboundrule-%[3]s" + workspace_id = azurerm_machine_learning_workspace.test.id + destination = "destination" +} +`, template, data.RandomInteger, data.RandomStringOfLength(6)) +} + +func (r WorkspaceNetworkOutboundRuleFqdnResource) update(data acceptance.TestData) string { + template := r.template(data) + return fmt.Sprintf(` +provider "azurerm" { + features { + key_vault { + purge_soft_delete_on_destroy = false + purge_soft_deleted_keys_on_destroy = false + } + resource_group { + prevent_deletion_if_contains_resources = false + } + } +} + +%[1]s + +resource "azurerm_machine_learning_workspace" "test" { + name = "acctest-MLW-%[2]d" + location = azurerm_resource_group.test.location + resource_group_name = azurerm_resource_group.test.name + application_insights_id = azurerm_application_insights.test.id + key_vault_id = azurerm_key_vault.test.id + storage_account_id = azurerm_storage_account.test.id + + managed_network { + isolation_mode = "AllowOnlyApprovedOutbound" + } + + identity { + type = "SystemAssigned" + } +} + +resource "azurerm_machine_learning_workspace_network_outbound_rule_fqdn" "test" { + name = "acctest-MLW-outboundrule-%[3]s" + workspace_id = azurerm_machine_learning_workspace.test.id + destination = "destinationupdate" +} +`, template, data.RandomInteger, data.RandomStringOfLength(6)) +} + +func (r WorkspaceNetworkOutboundRuleFqdnResource) requiresImport(data acceptance.TestData) string { + template := r.basic(data) + return fmt.Sprintf(` +%s + +resource "azurerm_machine_learning_workspace_network_outbound_rule_fqdn" "import" { + name = azurerm_machine_learning_workspace_network_outbound_rule_fqdn.test.name + workspace_id = azurerm_machine_learning_workspace_network_outbound_rule_fqdn.test.workspace_id + destination = azurerm_machine_learning_workspace_network_outbound_rule_fqdn.test.destination +} +`, template) +} diff --git a/internal/services/machinelearning/registration.go b/internal/services/machinelearning/registration.go index 72f68b379622..ffcb53b87cf5 100644 --- a/internal/services/machinelearning/registration.go +++ b/internal/services/machinelearning/registration.go @@ -57,5 +57,6 @@ func (r Registration) Resources() []sdk.Resource { MachineLearningDataStoreBlobStorage{}, MachineLearningDataStoreDataLakeGen2{}, MachineLearningDataStoreFileShare{}, + WorkspaceNetworkOutboundRuleFqdn{}, } } diff --git a/website/docs/r/machine_learning_workspace_network_outboundrule_fqdn.html.markdown b/website/docs/r/machine_learning_workspace_network_outboundrule_fqdn.html.markdown new file mode 100644 index 000000000000..a748ffdeba0d --- /dev/null +++ b/website/docs/r/machine_learning_workspace_network_outboundrule_fqdn.html.markdown @@ -0,0 +1,106 @@ +--- +subcategory: "Machine Learning" +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_machine_learning_workspace_network_outbound_rule_fqdn" +description: |- + Manages an Azure Machine Learning Workspace FQDN Network Outbound Rule. +--- +# azurerm_machine_learning_workspace_network_outbound_rule_fqdn + +Manages an Azure Machine Learning Workspace FQDN Network Outbound Rule. + + +## Example Usage + +```hcl +provider "azurerm" { + features {} +} + +data "azurerm_client_config" "current" {} + +resource "azurerm_resource_group" "example" { + name = "example-resources" + location = "West Europe" +} + +resource "azurerm_application_insights" "example" { + name = "workspace-example-ai" + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.example.name + application_type = "web" +} + +resource "azurerm_key_vault" "example" { + name = "workspaceexamplekeyvault" + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.example.name + tenant_id = data.azurerm_client_config.current.tenant_id + sku_name = "premium" +} + +resource "azurerm_storage_account" "example" { + name = "workspacestorageaccount" + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.example.name + account_tier = "Standard" + account_replication_type = "GRS" +} + +resource "azurerm_machine_learning_workspace" "example" { + name = "example-workspace" + location = azurerm_resource_group.example.location + resource_group_name = azurerm_resource_group.example.name + application_insights_id = azurerm_application_insights.example.id + key_vault_id = azurerm_key_vault.example.id + storage_account_id = azurerm_storage_account.example.id + + managed_network { + isolation_mode = "AllowOnlyApprovedOutbound" + } + + identity { + type = "SystemAssigned" + } +} + +resource "azurerm_machine_learning_workspace_network_outbound_rule_fqdn" "example" { + name = "example-outboundrule" + workspace_id = azurerm_machine_learning_workspace.example.id + destination = "destination" +} +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name of the Machine Learning Workspace FQDN Network Outbound Rule. Changing this forces a new resource to be created. + +* `workspace_id` - (Required) Specifies the ID of the Machine Learning Workspace. Changing this forces a new resource to be created. + +* `destination` - (Required) Specifies the fully qualified domain name to allow for outbound traffic. + + +## Attributes Reference + +In addition to the Arguments listed above - the following Attributes are exported: + +* `id` - The ID of the Machine Learning Workspace. + +### Timeouts + +The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions: + +* `create` - (Defaults to 30 minutes) Used when creating the Machine Learning Workspace FQDN Network Outbound Rule. +* `update` - (Defaults to 30 minutes) Used when updating the Machine Learning Workspace FQDN Network Outbound Rule. +* `read` - (Defaults to 5 minutes) Used when retrieving the Machine Learning Workspace FQDN Network Outbound Rule. +* `delete` - (Defaults to 30 minutes) Used when deleting the Machine Learning Workspace FQDN Network Outbound Rule. + +## Import + +Machine Learning Workspace FQDN Network Outbound Rule can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_machine_learning_workspace_network_outbound_rule_fqdn.example /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/group1/providers/Microsoft.MachineLearningServices/workspaces/workspace1/outboundRules/rule1 +``` From e1230afb641870c268b756e11c55341e2efe1ff5 Mon Sep 17 00:00:00 2001 From: Xu Zhang Date: Fri, 13 Sep 2024 17:23:59 +0800 Subject: [PATCH 3/9] format doc --- ...learning_workspace_network_outboundrule_fqdn.html.markdown | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/website/docs/r/machine_learning_workspace_network_outboundrule_fqdn.html.markdown b/website/docs/r/machine_learning_workspace_network_outboundrule_fqdn.html.markdown index a748ffdeba0d..e719202899d2 100644 --- a/website/docs/r/machine_learning_workspace_network_outboundrule_fqdn.html.markdown +++ b/website/docs/r/machine_learning_workspace_network_outboundrule_fqdn.html.markdown @@ -54,11 +54,11 @@ resource "azurerm_machine_learning_workspace" "example" { application_insights_id = azurerm_application_insights.example.id key_vault_id = azurerm_key_vault.example.id storage_account_id = azurerm_storage_account.example.id - + managed_network { isolation_mode = "AllowOnlyApprovedOutbound" } - + identity { type = "SystemAssigned" } From ea6fb02eded6c0136b872618ae06a4b0e6475353 Mon Sep 17 00:00:00 2001 From: Xu Zhang Date: Sat, 14 Sep 2024 11:17:15 +0800 Subject: [PATCH 4/9] update vendor --- .../helper/resource/testing_new_import_state.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/vendor/github.com/hashicorp/terraform-plugin-testing/helper/resource/testing_new_import_state.go b/vendor/github.com/hashicorp/terraform-plugin-testing/helper/resource/testing_new_import_state.go index e0f8440af259..7dbc0b800b4d 100644 --- a/vendor/github.com/hashicorp/terraform-plugin-testing/helper/resource/testing_new_import_state.go +++ b/vendor/github.com/hashicorp/terraform-plugin-testing/helper/resource/testing_new_import_state.go @@ -264,16 +264,13 @@ func testStepNewImportState(ctx context.Context, t testing.T, helper *plugintest // Remove fields we're ignoring for _, v := range step.ImportStateVerifyIgnore { - fmt.Printf("ImportStateVerifyIgnore name: %s", v) for k := range actual { if strings.HasPrefix(k, v) { - fmt.Printf("ImportStateVerifyIgnore name: %s deleted in actual", v) delete(actual, k) } } for k := range expected { if strings.HasPrefix(k, v) { - fmt.Printf("ImportStateVerifyIgnore name: %s deleted in actual", v) delete(expected, k) } } From 4be4e4dec4b576a87476ce19fdf7bac56595657b Mon Sep 17 00:00:00 2001 From: Xu Zhang Date: Fri, 20 Sep 2024 13:56:52 +0800 Subject: [PATCH 5/9] update document --- ...e_learning_workspace_network_outboundrule_fqdn.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/docs/r/machine_learning_workspace_network_outboundrule_fqdn.html.markdown b/website/docs/r/machine_learning_workspace_network_outboundrule_fqdn.html.markdown index e719202899d2..82e56e85c000 100644 --- a/website/docs/r/machine_learning_workspace_network_outboundrule_fqdn.html.markdown +++ b/website/docs/r/machine_learning_workspace_network_outboundrule_fqdn.html.markdown @@ -86,7 +86,7 @@ The following arguments are supported: In addition to the Arguments listed above - the following Attributes are exported: -* `id` - The ID of the Machine Learning Workspace. +* `id` - The ID of the Machine Learning Workspace Network Outbound Rule. ### Timeouts From 93161fcf2fb946d536dab46b897207c101e9e78f Mon Sep 17 00:00:00 2001 From: Xu Zhang Date: Fri, 20 Sep 2024 14:02:56 +0800 Subject: [PATCH 6/9] rename document --- ...e_learning_workspace_network_outbound_rule_fqdn.html.markdown} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename website/docs/r/{machine_learning_workspace_network_outboundrule_fqdn.html.markdown => machine_learning_workspace_network_outbound_rule_fqdn.html.markdown} (100%) diff --git a/website/docs/r/machine_learning_workspace_network_outboundrule_fqdn.html.markdown b/website/docs/r/machine_learning_workspace_network_outbound_rule_fqdn.html.markdown similarity index 100% rename from website/docs/r/machine_learning_workspace_network_outboundrule_fqdn.html.markdown rename to website/docs/r/machine_learning_workspace_network_outbound_rule_fqdn.html.markdown From 42794286b759882b79e77155ce6357aa4dff56f8 Mon Sep 17 00:00:00 2001 From: Xu Zhang Date: Mon, 23 Sep 2024 13:22:01 +0800 Subject: [PATCH 7/9] fix acctests --- ...ng_workspace_network_outbound_rule_fqdn_resource_test.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/internal/services/machinelearning/machine_learning_workspace_network_outbound_rule_fqdn_resource_test.go b/internal/services/machinelearning/machine_learning_workspace_network_outbound_rule_fqdn_resource_test.go index a16c5edec3f1..4354ea75f9e7 100644 --- a/internal/services/machinelearning/machine_learning_workspace_network_outbound_rule_fqdn_resource_test.go +++ b/internal/services/machinelearning/machine_learning_workspace_network_outbound_rule_fqdn_resource_test.go @@ -59,7 +59,7 @@ func TestAccMachineLearningWorkspaceNetworkOutboundRuleFqdn_update(t *testing.T) }) } -func TestAccMachineLearningWorkspaceOutboundFqdn_requiresImport(t *testing.T) { +func TestAccMachineLearningWorkspaceNetworkOutboundRuleFqdn_requiresImport(t *testing.T) { data := acceptance.BuildTestData(t, "azurerm_machine_learning_workspace_network_outbound_rule_fqdn", "test") r := WorkspaceNetworkOutboundRuleFqdnResource{} @@ -181,7 +181,7 @@ resource "azurerm_machine_learning_workspace_network_outbound_rule_fqdn" "test" workspace_id = azurerm_machine_learning_workspace.test.id destination = "destination" } -`, template, data.RandomInteger, data.RandomStringOfLength(6)) +`, template, data.RandomInteger, data.RandomString) } func (r WorkspaceNetworkOutboundRuleFqdnResource) update(data acceptance.TestData) string { @@ -223,7 +223,7 @@ resource "azurerm_machine_learning_workspace_network_outbound_rule_fqdn" "test" workspace_id = azurerm_machine_learning_workspace.test.id destination = "destinationupdate" } -`, template, data.RandomInteger, data.RandomStringOfLength(6)) +`, template, data.RandomInteger, data.RandomString) } func (r WorkspaceNetworkOutboundRuleFqdnResource) requiresImport(data acceptance.TestData) string { From b51052351a200a07f34b967afcd695952217c888 Mon Sep 17 00:00:00 2001 From: Xu Zhang Date: Fri, 25 Oct 2024 11:30:51 +0800 Subject: [PATCH 8/9] rename destination to destination_fqdn --- ...ace_network_outbound_rule_fqdn_resource.go | 6 ++--- ...etwork_outbound_rule_fqdn_resource_test.go | 26 +++++++++---------- ...e_network_outbound_rule_fqdn.html.markdown | 8 +++--- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/internal/services/machinelearning/machine_learning_workspace_network_outbound_rule_fqdn_resource.go b/internal/services/machinelearning/machine_learning_workspace_network_outbound_rule_fqdn_resource.go index 19075d892207..5d619f764067 100644 --- a/internal/services/machinelearning/machine_learning_workspace_network_outbound_rule_fqdn_resource.go +++ b/internal/services/machinelearning/machine_learning_workspace_network_outbound_rule_fqdn_resource.go @@ -23,7 +23,7 @@ var _ sdk.ResourceWithUpdate = WorkspaceNetworkOutboundRuleFqdn{} type machineLearningWorkspaceOutboundRuleFqdnModel struct { Name string `tfschema:"name"` WorkspaceId string `tfschema:"workspace_id"` - Destination string `tfschema:"destination"` + Destination string `tfschema:"destination_fqdn"` } type WorkspaceNetworkOutboundRuleFqdn struct{} @@ -58,7 +58,7 @@ func (r WorkspaceNetworkOutboundRuleFqdn) Arguments() map[string]*pluginsdk.Sche ValidateFunc: managednetwork.ValidateWorkspaceID, }, - "destination": { + "destination_fqdn": { Type: pluginsdk.TypeString, Required: true, ValidateFunc: validation.StringIsNotEmpty, @@ -147,7 +147,7 @@ func (r WorkspaceNetworkOutboundRuleFqdn) Update() sdk.ResourceFunc { payload := existing.Model - if metadata.ResourceData.HasChange("destination") { + if metadata.ResourceData.HasChange("destination_fqdn") { payload.Properties = managednetwork.FqdnOutboundRule{ Destination: &model.Destination, } diff --git a/internal/services/machinelearning/machine_learning_workspace_network_outbound_rule_fqdn_resource_test.go b/internal/services/machinelearning/machine_learning_workspace_network_outbound_rule_fqdn_resource_test.go index 4354ea75f9e7..c825ff955cc0 100644 --- a/internal/services/machinelearning/machine_learning_workspace_network_outbound_rule_fqdn_resource_test.go +++ b/internal/services/machinelearning/machine_learning_workspace_network_outbound_rule_fqdn_resource_test.go @@ -28,7 +28,7 @@ func TestAccMachineLearningWorkspaceNetworkOutboundRuleFqdn_basic(t *testing.T) Config: r.basic(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("destination").Exists(), + check.That(data.ResourceName).Key("destination_fqdn").Exists(), ), }, data.ImportStep(), @@ -44,7 +44,7 @@ func TestAccMachineLearningWorkspaceNetworkOutboundRuleFqdn_update(t *testing.T) Config: r.basic(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("destination").Exists(), + check.That(data.ResourceName).Key("destination_fqdn").Exists(), ), }, data.ImportStep(), @@ -52,7 +52,7 @@ func TestAccMachineLearningWorkspaceNetworkOutboundRuleFqdn_update(t *testing.T) Config: r.update(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("destination").HasValue("destinationupdate"), + check.That(data.ResourceName).Key("destination_fqdn").HasValue("destinationupdate"), ), }, data.ImportStep(), @@ -68,7 +68,7 @@ func TestAccMachineLearningWorkspaceNetworkOutboundRuleFqdn_requiresImport(t *te Config: r.basic(data), Check: acceptance.ComposeTestCheckFunc( check.That(data.ResourceName).ExistsInAzure(r), - check.That(data.ResourceName).Key("destination").Exists(), + check.That(data.ResourceName).Key("destination_fqdn").Exists(), ), }, data.RequiresImportErrorStep(r.requiresImport), @@ -177,9 +177,9 @@ resource "azurerm_machine_learning_workspace" "test" { } resource "azurerm_machine_learning_workspace_network_outbound_rule_fqdn" "test" { - name = "acctest-MLW-outboundrule-%[3]s" - workspace_id = azurerm_machine_learning_workspace.test.id - destination = "destination" + name = "acctest-MLW-outboundrule-%[3]s" + workspace_id = azurerm_machine_learning_workspace.test.id + destination_fqdn = "destination" } `, template, data.RandomInteger, data.RandomString) } @@ -219,9 +219,9 @@ resource "azurerm_machine_learning_workspace" "test" { } resource "azurerm_machine_learning_workspace_network_outbound_rule_fqdn" "test" { - name = "acctest-MLW-outboundrule-%[3]s" - workspace_id = azurerm_machine_learning_workspace.test.id - destination = "destinationupdate" + name = "acctest-MLW-outboundrule-%[3]s" + workspace_id = azurerm_machine_learning_workspace.test.id + destination_fqdn = "destinationupdate" } `, template, data.RandomInteger, data.RandomString) } @@ -232,9 +232,9 @@ func (r WorkspaceNetworkOutboundRuleFqdnResource) requiresImport(data acceptance %s resource "azurerm_machine_learning_workspace_network_outbound_rule_fqdn" "import" { - name = azurerm_machine_learning_workspace_network_outbound_rule_fqdn.test.name - workspace_id = azurerm_machine_learning_workspace_network_outbound_rule_fqdn.test.workspace_id - destination = azurerm_machine_learning_workspace_network_outbound_rule_fqdn.test.destination + name = azurerm_machine_learning_workspace_network_outbound_rule_fqdn.test.name + workspace_id = azurerm_machine_learning_workspace_network_outbound_rule_fqdn.test.workspace_id + destination_fqdn = azurerm_machine_learning_workspace_network_outbound_rule_fqdn.test.destination_fqdn } `, template) } diff --git a/website/docs/r/machine_learning_workspace_network_outbound_rule_fqdn.html.markdown b/website/docs/r/machine_learning_workspace_network_outbound_rule_fqdn.html.markdown index 82e56e85c000..a7d01016777a 100644 --- a/website/docs/r/machine_learning_workspace_network_outbound_rule_fqdn.html.markdown +++ b/website/docs/r/machine_learning_workspace_network_outbound_rule_fqdn.html.markdown @@ -65,9 +65,9 @@ resource "azurerm_machine_learning_workspace" "example" { } resource "azurerm_machine_learning_workspace_network_outbound_rule_fqdn" "example" { - name = "example-outboundrule" - workspace_id = azurerm_machine_learning_workspace.example.id - destination = "destination" + name = "example-outboundrule" + workspace_id = azurerm_machine_learning_workspace.example.id + destination_fqdn = "example.com" } ``` @@ -79,7 +79,7 @@ The following arguments are supported: * `workspace_id` - (Required) Specifies the ID of the Machine Learning Workspace. Changing this forces a new resource to be created. -* `destination` - (Required) Specifies the fully qualified domain name to allow for outbound traffic. +* `destination_fqdn` - (Required) Specifies the fully qualified domain name to allow for outbound traffic. ## Attributes Reference From 2d6d9a9bf26ab647a6f72636049e2abc0bf9b894 Mon Sep 17 00:00:00 2001 From: Xu Zhang Date: Fri, 25 Oct 2024 13:30:13 +0800 Subject: [PATCH 9/9] update vendor files --- .../2024-04-01/managednetwork/README.md | 12 ++--- .../2024-04-01/managednetwork/client.go | 2 +- .../managednetwork/id_outboundrule.go | 8 ++-- .../2024-04-01/managednetwork/id_workspace.go | 6 +-- .../managednetwork/method_settingsruleget.go | 1 - .../managednetwork/model_fqdnoutboundrule.go | 13 ++++- .../managednetwork/model_outboundrule.go | 48 ++++++++++++++----- .../model_outboundrulebasicresource.go | 13 +++-- .../model_privateendpointoutboundrule.go | 13 ++++- .../model_servicetagoutboundrule.go | 13 ++++- .../2024-04-01/managednetwork/version.go | 4 +- 11 files changed, 96 insertions(+), 37 deletions(-) diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/README.md b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/README.md index 6ab495a888f8..5c7c9360fe3f 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/README.md +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/README.md @@ -1,7 +1,7 @@ ## `github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork` Documentation -The `managednetwork` SDK allows for interaction with the Azure Resource Manager Service `machinelearningservices` (API Version `2024-04-01`). +The `managednetwork` SDK allows for interaction with Azure Resource Manager `machinelearningservices` (API Version `2024-04-01`). This readme covers example usages, but further information on [using this SDK can be found in the project root](https://github.com/hashicorp/go-azure-sdk/tree/main/docs). @@ -24,7 +24,7 @@ client.Client.Authorizer = authorizer ```go ctx := context.TODO() -id := managednetwork.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue") +id := managednetwork.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName") payload := managednetwork.ManagedNetworkProvisionOptions{ // ... @@ -41,7 +41,7 @@ if err := client.ProvisionsProvisionManagedNetworkThenPoll(ctx, id, payload); er ```go ctx := context.TODO() -id := managednetwork.NewOutboundRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "outboundRuleValue") +id := managednetwork.NewOutboundRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "outboundRuleName") payload := managednetwork.OutboundRuleBasicResource{ // ... @@ -58,7 +58,7 @@ if err := client.SettingsRuleCreateOrUpdateThenPoll(ctx, id, payload); err != ni ```go ctx := context.TODO() -id := managednetwork.NewOutboundRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "outboundRuleValue") +id := managednetwork.NewOutboundRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "outboundRuleName") if err := client.SettingsRuleDeleteThenPoll(ctx, id); err != nil { // handle the error @@ -70,7 +70,7 @@ if err := client.SettingsRuleDeleteThenPoll(ctx, id); err != nil { ```go ctx := context.TODO() -id := managednetwork.NewOutboundRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue", "outboundRuleValue") +id := managednetwork.NewOutboundRuleID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceName", "outboundRuleName") read, err := client.SettingsRuleGet(ctx, id) if err != nil { @@ -86,7 +86,7 @@ if model := read.Model; model != nil { ```go ctx := context.TODO() -id := managednetwork.NewWorkspaceID("12345678-1234-9876-4563-123456789012", "example-resource-group", "workspaceValue") +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) diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/client.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/client.go index 6313700a6ea5..7167dbc42a44 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/client.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/client.go @@ -15,7 +15,7 @@ type ManagedNetworkClient struct { } func NewManagedNetworkClientWithBaseURI(sdkApi sdkEnv.Api) (*ManagedNetworkClient, error) { - client, err := resourcemanager.NewResourceManagerClient(sdkApi, "managednetwork", defaultApiVersion) + client, err := resourcemanager.NewClient(sdkApi, "managednetwork", defaultApiVersion) if err != nil { return nil, fmt.Errorf("instantiating ManagedNetworkClient: %+v", err) } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/id_outboundrule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/id_outboundrule.go index e8f379567d6d..16202df94be6 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/id_outboundrule.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/id_outboundrule.go @@ -44,7 +44,7 @@ func ParseOutboundRuleID(input string) (*OutboundRuleId, error) { } id := OutboundRuleId{} - if err := id.FromParseResult(*parsed); err != nil { + if err = id.FromParseResult(*parsed); err != nil { return nil, err } @@ -61,7 +61,7 @@ func ParseOutboundRuleIDInsensitively(input string) (*OutboundRuleId, error) { } id := OutboundRuleId{} - if err := id.FromParseResult(*parsed); err != nil { + if err = id.FromParseResult(*parsed); err != nil { return nil, err } @@ -121,9 +121,9 @@ func (id OutboundRuleId) Segments() []resourceids.Segment { resourceids.StaticSegment("staticProviders", "providers", "providers"), resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), - resourceids.UserSpecifiedSegment("workspaceName", "workspaceValue"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), resourceids.StaticSegment("staticOutboundRules", "outboundRules", "outboundRules"), - resourceids.UserSpecifiedSegment("outboundRuleName", "outboundRuleValue"), + resourceids.UserSpecifiedSegment("outboundRuleName", "outboundRuleName"), } } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/id_workspace.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/id_workspace.go index cd60cc5e74a5..f90b3b238856 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/id_workspace.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/id_workspace.go @@ -42,7 +42,7 @@ func ParseWorkspaceID(input string) (*WorkspaceId, error) { } id := WorkspaceId{} - if err := id.FromParseResult(*parsed); err != nil { + if err = id.FromParseResult(*parsed); err != nil { return nil, err } @@ -59,7 +59,7 @@ func ParseWorkspaceIDInsensitively(input string) (*WorkspaceId, error) { } id := WorkspaceId{} - if err := id.FromParseResult(*parsed); err != nil { + if err = id.FromParseResult(*parsed); err != nil { return nil, err } @@ -115,7 +115,7 @@ func (id WorkspaceId) Segments() []resourceids.Segment { resourceids.StaticSegment("staticProviders", "providers", "providers"), resourceids.ResourceProviderSegment("staticMicrosoftMachineLearningServices", "Microsoft.MachineLearningServices", "Microsoft.MachineLearningServices"), resourceids.StaticSegment("staticWorkspaces", "workspaces", "workspaces"), - resourceids.UserSpecifiedSegment("workspaceName", "workspaceValue"), + resourceids.UserSpecifiedSegment("workspaceName", "workspaceName"), } } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/method_settingsruleget.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/method_settingsruleget.go index 87f7ac2e3447..d9e4990d7838 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/method_settingsruleget.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/method_settingsruleget.go @@ -45,7 +45,6 @@ func (c ManagedNetworkClient) SettingsRuleGet(ctx context.Context, id OutboundRu var model OutboundRuleBasicResource result.Model = &model - if err = resp.Unmarshal(result.Model); err != nil { return } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_fqdnoutboundrule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_fqdnoutboundrule.go index 70921895572b..c68f41f0977d 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_fqdnoutboundrule.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_fqdnoutboundrule.go @@ -14,8 +14,18 @@ type FqdnOutboundRule struct { Destination *string `json:"destination,omitempty"` // Fields inherited from OutboundRule + Category *RuleCategory `json:"category,omitempty"` Status *RuleStatus `json:"status,omitempty"` + Type RuleType `json:"type"` +} + +func (s FqdnOutboundRule) OutboundRule() BaseOutboundRuleImpl { + return BaseOutboundRuleImpl{ + Category: s.Category, + Status: s.Status, + Type: s.Type, + } } var _ json.Marshaler = FqdnOutboundRule{} @@ -29,9 +39,10 @@ func (s FqdnOutboundRule) MarshalJSON() ([]byte, error) { } var decoded map[string]interface{} - if err := json.Unmarshal(encoded, &decoded); err != nil { + if err = json.Unmarshal(encoded, &decoded); err != nil { return nil, fmt.Errorf("unmarshaling FqdnOutboundRule: %+v", err) } + decoded["type"] = "FQDN" encoded, err = json.Marshal(decoded) diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_outboundrule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_outboundrule.go index 8e5529b02dce..592574a294e1 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_outboundrule.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_outboundrule.go @@ -10,18 +10,37 @@ import ( // Licensed under the MIT License. See NOTICE.txt in the project root for license information. type OutboundRule interface { + OutboundRule() BaseOutboundRuleImpl } -// RawOutboundRuleImpl is returned when the Discriminated Value -// doesn't match any of the defined types +var _ OutboundRule = BaseOutboundRuleImpl{} + +type BaseOutboundRuleImpl struct { + Category *RuleCategory `json:"category,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 { - Type string - Values map[string]interface{} + outboundRule BaseOutboundRuleImpl + Type string + Values map[string]interface{} +} + +func (s RawOutboundRuleImpl) OutboundRule() BaseOutboundRuleImpl { + return s.outboundRule } -func unmarshalOutboundRuleImplementation(input []byte) (OutboundRule, error) { +func UnmarshalOutboundRuleImplementation(input []byte) (OutboundRule, error) { if input == nil { return nil, nil } @@ -31,9 +50,9 @@ func unmarshalOutboundRuleImplementation(input []byte) (OutboundRule, error) { return nil, fmt.Errorf("unmarshaling OutboundRule into map[string]interface: %+v", err) } - value, ok := temp["type"].(string) - if !ok { - return nil, nil + var value string + if v, ok := temp["type"]; ok { + value = fmt.Sprintf("%v", v) } if strings.EqualFold(value, "FQDN") { @@ -60,10 +79,15 @@ func unmarshalOutboundRuleImplementation(input []byte) (OutboundRule, error) { return out, nil } - out := RawOutboundRuleImpl{ - Type: value, - Values: temp, + var parent BaseOutboundRuleImpl + if err := json.Unmarshal(input, &parent); err != nil { + return nil, fmt.Errorf("unmarshaling into BaseOutboundRuleImpl: %+v", err) } - return out, nil + + return RawOutboundRuleImpl{ + outboundRule: parent, + Type: value, + Values: temp, + }, nil } diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_outboundrulebasicresource.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_outboundrulebasicresource.go index 8c333ed73f1c..8abeca48308c 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_outboundrulebasicresource.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_outboundrulebasicresource.go @@ -21,10 +21,14 @@ type OutboundRuleBasicResource struct { var _ json.Unmarshaler = &OutboundRuleBasicResource{} func (s *OutboundRuleBasicResource) UnmarshalJSON(bytes []byte) error { - type alias OutboundRuleBasicResource - var decoded alias + 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 into OutboundRuleBasicResource: %+v", err) + return fmt.Errorf("unmarshaling: %+v", err) } s.Id = decoded.Id @@ -38,11 +42,12 @@ func (s *OutboundRuleBasicResource) UnmarshalJSON(bytes []byte) error { } if v, ok := temp["properties"]; ok { - impl, err := unmarshalOutboundRuleImplementation(v) + 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/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_privateendpointoutboundrule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_privateendpointoutboundrule.go index da6f88ed30cf..6bda20dd829c 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_privateendpointoutboundrule.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_privateendpointoutboundrule.go @@ -14,8 +14,18 @@ type PrivateEndpointOutboundRule struct { Destination *PrivateEndpointDestination `json:"destination,omitempty"` // Fields inherited from OutboundRule + Category *RuleCategory `json:"category,omitempty"` Status *RuleStatus `json:"status,omitempty"` + Type RuleType `json:"type"` +} + +func (s PrivateEndpointOutboundRule) OutboundRule() BaseOutboundRuleImpl { + return BaseOutboundRuleImpl{ + Category: s.Category, + Status: s.Status, + Type: s.Type, + } } var _ json.Marshaler = PrivateEndpointOutboundRule{} @@ -29,9 +39,10 @@ func (s PrivateEndpointOutboundRule) MarshalJSON() ([]byte, error) { } var decoded map[string]interface{} - if err := json.Unmarshal(encoded, &decoded); err != nil { + if err = json.Unmarshal(encoded, &decoded); err != nil { return nil, fmt.Errorf("unmarshaling PrivateEndpointOutboundRule: %+v", err) } + decoded["type"] = "PrivateEndpoint" encoded, err = json.Marshal(decoded) diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_servicetagoutboundrule.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_servicetagoutboundrule.go index 2bb23ca8815d..268a1b09c833 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_servicetagoutboundrule.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/model_servicetagoutboundrule.go @@ -14,8 +14,18 @@ type ServiceTagOutboundRule struct { Destination *ServiceTagDestination `json:"destination,omitempty"` // Fields inherited from OutboundRule + Category *RuleCategory `json:"category,omitempty"` Status *RuleStatus `json:"status,omitempty"` + Type RuleType `json:"type"` +} + +func (s ServiceTagOutboundRule) OutboundRule() BaseOutboundRuleImpl { + return BaseOutboundRuleImpl{ + Category: s.Category, + Status: s.Status, + Type: s.Type, + } } var _ json.Marshaler = ServiceTagOutboundRule{} @@ -29,9 +39,10 @@ func (s ServiceTagOutboundRule) MarshalJSON() ([]byte, error) { } var decoded map[string]interface{} - if err := json.Unmarshal(encoded, &decoded); err != nil { + if err = json.Unmarshal(encoded, &decoded); err != nil { return nil, fmt.Errorf("unmarshaling ServiceTagOutboundRule: %+v", err) } + decoded["type"] = "ServiceTag" encoded, err = json.Marshal(decoded) diff --git a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/version.go b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/version.go index 61486bdd2250..178ee734db3c 100644 --- a/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/version.go +++ b/vendor/github.com/hashicorp/go-azure-sdk/resource-manager/machinelearningservices/2024-04-01/managednetwork/version.go @@ -1,12 +1,10 @@ package managednetwork -import "fmt" - // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. See NOTICE.txt in the project root for license information. const defaultApiVersion = "2024-04-01" func userAgent() string { - return fmt.Sprintf("hashicorp/go-azure-sdk/managednetwork/%s", defaultApiVersion) + return "hashicorp/go-azure-sdk/managednetwork/2024-04-01" }